Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 222859 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java (+115 lines)
Lines 126-131 Link Here
126
	NSRect fullScreenFrame;
126
	NSRect fullScreenFrame;
127
	ToolBar toolBar;
127
	ToolBar toolBar;
128
	
128
	
129
	/* Trim bar */
130
	NSToolbarItem trimBarItem;
131
	NSToolbar trimBarToolbar;
132
	NSView trimBarView;
133
	NSString trimBarID;
134
	Composite trimArea;
135
	
129
	static int DEFAULT_CLIENT_WIDTH = -1;
136
	static int DEFAULT_CLIENT_WIDTH = -1;
130
	static int DEFAULT_CLIENT_HEIGHT = -1;
137
	static int DEFAULT_CLIENT_HEIGHT = -1;
131
138
Lines 715-720 Link Here
715
	} else {
722
	} else {
716
		display.removeWidget (view.window());
723
		display.removeWidget (view.window());
717
	}
724
	}
725
	if (trimBarView != null) display.removeWidget(trimBarView);
726
	if (trimBarToolbar != null) display.removeWidget (trimBarToolbar);
718
	if (windowDelegate != null) display.removeWidget (windowDelegate);
727
	if (windowDelegate != null) display.removeWidget (windowDelegate);
719
}
728
}
720
729
Lines 1137-1146 Link Here
1137
 */
1146
 */
1138
public ToolBar getToolBar() {
1147
public ToolBar getToolBar() {
1139
	checkWidget();
1148
	checkWidget();
1149
	// FIXME: Is this the right thing to do?
1150
	if (trimArea != null) return null;
1140
	if (toolBar == null) toolBar = new ToolBar(this, SWT.HORIZONTAL | SWT.SMOOTH, true);
1151
	if (toolBar == null) toolBar = new ToolBar(this, SWT.HORIZONTAL | SWT.SMOOTH, true);
1141
	return toolBar;
1152
	return toolBar;
1142
}
1153
}
1143
1154
1155
public Composite getTrimBar() {
1156
	checkWidget();
1157
	if (toolBar != null) return toolBar;
1158
	if (trimArea != null) return trimArea;
1159
	
1160
	// Composite must have clear background or the window content color will show through.
1161
	trimArea = new Composite(this, SWT.NO_BACKGROUND);
1162
1163
	// Create an NSToolbar and NSToolbarItem that will hold the Composite's view.
1164
	trimBarToolbar = ((NSToolbar)new SWTToolbar().alloc()).initWithIdentifier(NSString.stringWith(String.valueOf(ToolBar.NEXT_ID++)));
1165
	trimBarToolbar.setDelegate(trimBarToolbar);
1166
	
1167
	// Track the widget right away, as many of these calls use the delegate methods. 
1168
	display.addWidget (trimBarToolbar, this);
1169
	trimBarToolbar.setDisplayMode(OS.NSToolbarDisplayModeIconOnly);
1170
	trimBarToolbar.setVisible(true);
1171
	trimBarID = NSString.stringWith(String.valueOf(ToolBar.NEXT_ID++));
1172
	trimBarID.retain();
1173
	trimBarItem = ((NSToolbarItem)new NSToolbarItem().alloc()).initWithItemIdentifier(trimBarID);
1174
	trimBarToolbar.insertItemWithItemIdentifier(trimBarID, 0);
1175
	
1176
	// setView moves the Composite's view to the toolbar.
1177
	trimBarItem.setView(trimArea.topView());
1178
	window.setToolbar(trimBarToolbar);
1179
	
1180
	// Need to change the toolbar view to an SWTToolbarView so mouseDownCanMoveWindow can be overridden.
1181
	NSArray views = window.contentView().superview().subviews();
1182
	for (int i = 0; i < views.count(); i++) {
1183
		NSView view = new NSView(views.objectAtIndex(i).id);
1184
		if (view.className().getString().equals("NSToolbarView")) {
1185
			trimBarView = view;
1186
			trimBarView.retain();
1187
			OS.object_setClass(trimBarView.id, OS.objc_getClass("SWTToolbarView"));
1188
			display.addWidget(trimBarView, this);
1189
			break;
1190
		}
1191
	}
1192
1193
	// Keep the min/max size of the item in sync with the size of the Composite.
1194
	trimArea.addControlListener(new ControlAdapter() {
1195
		public void controlResized(ControlEvent e) {
1196
			NSSize newSize = new NSSize();
1197
			newSize.width = trimArea.getSize().x;
1198
			newSize.height = trimArea.getSize().y;
1199
			trimBarItem.setView(null);
1200
			trimBarItem.setMaxSize(newSize);
1201
			trimBarItem.setMinSize(newSize);
1202
			trimBarItem.setView(trimArea.topView());
1203
		}		
1204
	});
1205
	
1206
	return trimArea;
1207
}
1208
1144
boolean hasBorder () {
1209
boolean hasBorder () {
1145
	return false;
1210
	return false;
1146
}
1211
}
Lines 1231-1236 Link Here
1231
	return new Point (width, height);
1296
	return new Point (width, height);
1232
}
1297
}
1233
1298
1299
boolean mouseDownCanMoveWindow(int /*long*/ id, int /*long*/ sel) {
1300
	if (id == trimArea.topView().id) {
1301
		return false;
1302
	}
1303
	return super.mouseDownCanMoveWindow(id, sel);
1304
}
1305
1234
void mouseMoved(int /*long*/ id, int /*long*/ sel, int /*long*/ theEvent) {
1306
void mouseMoved(int /*long*/ id, int /*long*/ sel, int /*long*/ theEvent) {
1235
	super.mouseMoved(id, sel, theEvent);
1307
	super.mouseMoved(id, sel, theEvent);
1236
1308
Lines 1340-1345 Link Here
1340
	NSNotificationCenter.defaultCenter().removeObserver(windowDelegate);
1412
	NSNotificationCenter.defaultCenter().removeObserver(windowDelegate);
1341
	if (windowDelegate != null) windowDelegate.release();
1413
	if (windowDelegate != null) windowDelegate.release();
1342
	windowDelegate = null;
1414
	windowDelegate = null;
1415
	
1416
	if (trimBarToolbar != null) {
1417
		trimBarToolbar.removeItemAtIndex(0);
1418
		trimBarItem.release();
1419
		trimBarItem = null;
1420
		window.setToolbar(null);
1421
		trimBarView.release();
1422
		trimBarView = null;
1423
		trimBarToolbar.release();
1424
		trimBarToolbar = null;
1425
		trimBarID.release();
1426
		trimBarID = null;
1427
	}
1428
	
1343
	super.releaseHandle ();
1429
	super.releaseHandle ();
1344
	window = null;
1430
	window = null;
1345
}
1431
}
Lines 1942-1947 Link Here
1942
	}
2028
	}
1943
}
2029
}
1944
2030
2031
int /*long*/ toolbar_itemForItemIdentifier_willBeInsertedIntoToolbar(int /*long*/ id, int /*long*/ sel, int /*long*/ toolbar, int /*long*/ itemIdentifier, boolean flag) {
2032
	return trimBarItem.id;
2033
}
2034
2035
/*
2036
 * Returns an array of all toolbar item IDs allowed to be in the toolbar. Since the ToolBar created all of the ToolItems
2037
 * return all of the item IDs.
2038
 */
2039
int /*long*/ toolbarAllowedItemIdentifiers(int /*long*/ id, int /*long*/ sel, int /*long*/ toolbar) {
2040
	NSMutableArray array = NSMutableArray.arrayWithCapacity(1);
2041
	array.addObject(trimBarItem.itemIdentifier());
2042
	return array.id;
2043
}
2044
2045
/*
2046
 * This delegate method isn't really needed because ToolBars aren't customizable, but it's required according to the documentation.
2047
 */
2048
int /*long*/ toolbarDefaultItemIdentifiers(int /*long*/ id, int /*long*/ sel, int /*long*/ toolbar) {
2049
	return toolbarAllowedItemIdentifiers(id, sel, toolbar);
2050
}
2051
2052
/*
2053
 * toolbarSelectableItemIdentifiers returns an array of all items that can be the selected item, as determined
2054
 * by setSelectedItemIdentifier. 
2055
 */
2056
int /*long*/ toolbarSelectableItemIdentifiers(int /*long*/ id, int /*long*/ sel, int /*long*/ toolbar) {
2057
	return 0;
2058
}
2059
1945
boolean traverseEscape () {
2060
boolean traverseEscape () {
1946
	if (parent == null) return false;
2061
	if (parent == null) return false;
1947
	if (!isVisible () || !isEnabled ()) return false;
2062
	if (!isVisible () || !isEnabled ()) return false;

Return to bug 222859