NSScreen getPrimaryScreen () { NSArray screens = NSScreen.screens(); return new NSScreen(screens.objectAtIndex(0)); }
boolean tableView_shouldReorderColumn_toColumn(long /*int*/ id, long /*int*/ sel, long /*int*/ aTableView, long /*int*/ currentColIndex, long /*int*/ newColIndex) { // Check column should never move and no column can be dragged to the left of it, if present. if ((style & SWT.CHECK) != 0) { if (currentColIndex == 0) return false; if (newColIndex == 0) return false; } NSTableView widget = new NSTableView(aTableView); id nsColumn = widget.tableColumns().objectAtIndex(currentColIndex); for (int i = 0; i < columnCount; i++) { if (columns[i].nsColumn.id == nsColumn.id) { return columns[i].movable; } } return true; }
boolean outlineView_shouldReorderColumn_toColumn(long /*int*/ id, long /*int*/ sel, long /*int*/ aTableView, long /*int*/ currentColIndex, long /*int*/ newColIndex) { // Check column should never move and no column can be dragged to the left of it, if present. if ((style & SWT.CHECK) != 0) { if (currentColIndex == 0) return false; if (newColIndex == 0) return false; } NSOutlineView widget = new NSOutlineView(aTableView); id nsColumn = widget.tableColumns().objectAtIndex(currentColIndex); for (int i = 0; i < columnCount; i++) { if (columns[i].nsColumn.id == nsColumn.id) { return columns[i].movable; } } return true; }
public SWTMacHack () { NSArray screens = NSScreen.screens(); NSScreen screen = new NSScreen(screens.objectAtIndex(0)); this.screenScale = (float)screen.backingScaleFactor(); }
public SWTMacHack () { NSArray screens = NSScreen.screens(); NSScreen screen = new NSScreen(screens.objectAtIndex(0)); this.screenScale = (float)screen.backingScaleFactor(); }
NSRect getPrimaryFrame () { NSArray screens = NSScreen.screens(); return new NSScreen(screens.objectAtIndex(0)).frame(); }
Control [] _getChildren () { NSArray views = contentView().subviews(); int count = (int)/*64*/views.count(); Control [] children = new Control [count]; if (count == 0) return children; int j = 0; for (int i=0; i<count; i++){ Widget widget = display.getWidget (views.objectAtIndex (count - i - 1).id); if (widget != null && widget != this && widget instanceof Control) { children [j++] = (Control) widget; } } if (j == count) return children; Control [] newChildren = new Control [j]; System.arraycopy (children, 0, newChildren, 0, j); return newChildren; }
boolean hasDefaultButton () { NSArray windows = application.windows(); long /*int*/ count = windows.count(); for (int i = 0; i < count; i++) { NSWindow window = new NSWindow(windows.objectAtIndex(i)); if (window.defaultButtonCell() != null) { return true; } } return false; }
static String getCacheParentPath () { if (OS.VERSION >= 0x1060) { NSArray array = NSFileManager.defaultManager ().URLsForDirectory (OS.NSCachesDirectory, OS.NSUserDomainMask); if (array.count () > 0) { NSURL url = new NSURL (array.objectAtIndex (0)); return url.path ().getString () + Mozilla.SEPARATOR_OS + "eclipse"; //$NON-NLS-1$ } } String baseDir = System.getProperty ("user.home"); //$NON-NLS-1$ return baseDir + "/Library/Caches/eclipse"; //$NON-NLS-1$ }
id getCellForColumnAndRowParameter(id parameter, int childID) { id returnValue = null; NSArray parameterObject = new NSArray(parameter.id); if (parameterObject.count() == 2) { AccessibleTableEvent event = new AccessibleTableEvent(this); event.column = new NSNumber(parameterObject.objectAtIndex(0)).intValue(); event.row = new NSNumber(parameterObject.objectAtIndex(1)).intValue(); for (int i = 0; i < accessibleTableListenersSize(); i++) { AccessibleTableListener listener = (AccessibleTableListener)accessibleTableListeners.elementAt(i); listener.getCell(event); returnValue = event.accessible.delegate; } } return returnValue; }
NSTouch findTouchWithId(NSArray touches, NSObject identity) { long /*int*/ count = touches.count(); for (long /*int*/ i = 0; i < count; i++) { NSTouch aTouch = new NSTouch(touches.objectAtIndex(i).id); NSObject currIdentity = new NSObject(OS.objc_msgSend(aTouch.id, OS.sel_identity)); if (currIdentity.isEqual(identity)) return aTouch; } return null; }
public void run() { NSHTTPCookieStorage storage = NSHTTPCookieStorage.sharedHTTPCookieStorage(); NSArray cookies = storage.cookies(); int count = (int)/*64*/cookies.count (); for (int i = 0; i < count; i++) { NSHTTPCookie cookie = new NSHTTPCookie(cookies.objectAtIndex(i)); if (cookie.isSessionOnly()) { storage.deleteCookie(cookie); } } } };
Widget findTooltip (NSPoint pt) { NSTableView widget = (NSTableView)view; NSTableHeaderView headerView = widget.headerView(); if (headerView != null) { pt = headerView.convertPoint_fromView_ (pt, null); long /*int*/ index = headerView.columnAtPoint (pt); if (index != -1) { NSArray nsColumns = widget.tableColumns (); id nsColumn = nsColumns.objectAtIndex (index); for (int i = 0; i < columnCount; i++) { TreeColumn column = columns [i]; if (column.nsColumn.id == nsColumn.id) { return column; } } } } return super.findTooltip (pt); }
Widget findTooltip (NSPoint pt) { NSTableView widget = (NSTableView)view; NSTableHeaderView headerView = widget.headerView(); if (headerView != null) { pt = headerView.convertPoint_fromView_ (pt, null); long /*int*/ index = headerView.columnAtPoint (pt); if (index != -1) { NSArray nsColumns = widget.tableColumns (); id nsColumn = nsColumns.objectAtIndex (index); for (int i = 0; i < columnCount; i++) { TableColumn column = columns [i]; if (column.nsColumn.id == nsColumn.id) { return column; } } } } return super.findTooltip (pt); }
void updateCursorRects (boolean enabled, NSView widget) { if (enabled) { widget.resetCursorRects (); widget.updateTrackingAreas (); } else { widget.discardCursorRects (); NSArray areas = widget.trackingAreas (); for (int i = 0; i < areas.count(); i++) { widget.removeTrackingArea (new NSTrackingArea (areas.objectAtIndex (i))); } } }
void sendDoubleSelection() { NSTableView tableView = (NSTableView)view; int rowIndex = (int)/*64*/tableView.clickedRow (); if (rowIndex == -1) rowIndex = (int)/*64*/tableView.selectedRow(); if (rowIndex != -1) { if ((style & SWT.CHECK) != 0) { NSArray columns = tableView.tableColumns (); int columnIndex = (int)/*64*/tableView.clickedColumn (); if (columnIndex != -1) { id column = columns.objectAtIndex (columnIndex); if (column.id == checkColumn.id) return; } } Event event = new Event (); event.item = _getItem (rowIndex); sendSelectionEvent (SWT.DefaultSelection, event, false); } }
void sendDoubleSelection() { NSOutlineView outlineView = (NSOutlineView)view; int rowIndex = (int)/*64*/outlineView.clickedRow (); if (rowIndex == -1) rowIndex = (int)/*64*/outlineView.selectedRow (); if (rowIndex != -1) { if ((style & SWT.CHECK) != 0) { NSArray columns = outlineView.tableColumns (); int columnIndex = (int)/*64*/outlineView.clickedColumn (); if (columnIndex != -1) { id column = columns.objectAtIndex (columnIndex); if (column.id == checkColumn.id) return; } } TreeItem item = (TreeItem) display.getWidget (outlineView.itemAtRow (rowIndex).id); Event event = new Event (); event.item = item; sendSelectionEvent (SWT.DefaultSelection, event, false); } }
public void run () { NSURL url = NSURL.URLWithString (NSString.stringWith (CookieUrl)); NSMutableDictionary headers = NSMutableDictionary.dictionaryWithCapacity (1); headers.setValue (NSString.stringWith (CookieValue), NSString.stringWith (HEADER_SETCOOKIE)); NSArray cookies = NSHTTPCookie.cookiesWithResponseHeaderFields (headers, url); if (cookies.count () == 0) return; NSHTTPCookieStorage storage = NSHTTPCookieStorage.sharedHTTPCookieStorage (); NSHTTPCookie cookie = new NSHTTPCookie (cookies.objectAtIndex (0)); storage.setCookie (cookie); CookieResult = true; } };
void setFrameSize(long /*int*/ id, long /*int*/ sel, NSSize size) { super.setFrameSize (id, sel, size); /* * Bug in Cocoa. When a search field is resized while having * focus, its editor is not properly positioned within the * widget. The fix is to reposition the editor. */ if ((style & SWT.SEARCH) != 0) { NSSearchField widget = (NSSearchField)view; NSText editor = widget.currentEditor (); if (editor != null) { NSArray subviews = widget.subviews (); if (subviews.count () > 0) { NSRect rect = widget.cell ().drawingRectForBounds (widget.bounds ()); new NSView (subviews.objectAtIndex (0)).setFrame (rect); } } } }
public void run () { NSHTTPCookieStorage storage = NSHTTPCookieStorage.sharedHTTPCookieStorage (); NSURL url = NSURL.URLWithString (NSString.stringWith (CookieUrl)); NSArray cookies = storage.cookiesForURL (url); int count = (int)/*64*/cookies.count (); if (count == 0) return; NSString name = NSString.stringWith (CookieName); for (int i = 0; i < count; i++) { NSHTTPCookie current = new NSHTTPCookie (cookies.objectAtIndex (i)); if (current.name ().compare (name) == OS.NSOrderedSame) { CookieValue = current.value ().getString (); return; } } } };