X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/20196e15ee74362130799968e1ac716b2c705836..9db177273906bb393b97b4a98f6a8b4d61e8f0e3:/src/osx/cocoa/listbox.mm?ds=sidebyside diff --git a/src/osx/cocoa/listbox.mm b/src/osx/cocoa/listbox.mm index 02a4c62f00..199363d247 100644 --- a/src/osx/cocoa/listbox.mm +++ b/src/osx/cocoa/listbox.mm @@ -4,7 +4,7 @@ // Author: Stefan Csomor // Modified by: // Created: 1998-01-01 -// RCS-ID: $Id: listbox.cpp 54820 2008-07-29 20:04:11Z SC $ +// RCS-ID: $Id$ // Copyright: (c) Stefan Csomor // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -161,7 +161,7 @@ protected : - (id) init { - [super init]; + self = [super init]; column = nil; return self; } @@ -224,7 +224,7 @@ protected: - (id) init { - [super init]; + self = [super init]; impl = nil; return self; } @@ -314,6 +314,24 @@ protected: } +- (void)setFont:(NSFont *)aFont +{ + NSArray *tableColumns = [self tableColumns]; + unsigned int columnIndex = [tableColumns count]; + while (columnIndex--) + [[(NSTableColumn *)[tableColumns objectAtIndex:columnIndex] dataCell] setFont:aFont]; + + [self setRowHeight:[gNSLayoutManager defaultLineHeightForFont:aFont]+2]; +} + +- (void) setControlSize:(NSControlSize) size +{ + NSArray *tableColumns = [self tableColumns]; + unsigned int columnIndex = [tableColumns count]; + while (columnIndex--) + [[(NSTableColumn *)[tableColumns objectAtIndex:columnIndex] dataCell] setControlSize:size]; +} + @end // @@ -369,6 +387,11 @@ wxListWidgetColumn* wxListWidgetCocoaImpl::InsertTextColumn( unsigned pos, const [col1 setWidth:1000]; } [col1 setResizingMask: NSTableColumnAutoresizingMask]; + + wxListBox *list = static_cast ( GetWXPeer()); + if ( list != NULL ) + [[col1 dataCell] setFont:list->GetFont().OSXGetNSFont()]; + wxCocoaTableColumn* wxcol = new wxCocoaTableColumn( col1, editable ); [col1 setColumn:wxcol]; @@ -388,6 +411,39 @@ wxListWidgetColumn* wxListWidgetCocoaImpl::InsertCheckColumn( unsigned pos , con [checkbox setTitle:@""]; [checkbox setButtonType:NSSwitchButton]; [col1 setDataCell:checkbox] ; + + wxListBox *list = static_cast ( GetWXPeer()); + if ( list != NULL ) + { + NSControlSize size = NSRegularControlSize; + + switch ( list->GetWindowVariant() ) + { + case wxWINDOW_VARIANT_NORMAL : + size = NSRegularControlSize; + break ; + + case wxWINDOW_VARIANT_SMALL : + size = NSSmallControlSize; + break ; + + case wxWINDOW_VARIANT_MINI : + size = NSMiniControlSize; + break ; + + case wxWINDOW_VARIANT_LARGE : + size = NSRegularControlSize; + break ; + + default: + break ; + } + + [[col1 dataCell] setControlSize:size]; + // although there is no text, it may help to get the correct vertical layout + [[col1 dataCell] setFont:list->GetFont().OSXGetNSFont()]; + } + [checkbox release]; unsigned formerColCount = [m_tableView numberOfColumns]; @@ -444,7 +500,8 @@ void wxListWidgetCocoaImpl::ListSetSelection( unsigned int n, bool select, bool { // TODO if ( select ) - [m_tableView selectRow: n byExtendingSelection:multi]; + [m_tableView selectRowIndexes:[NSIndexSet indexSetWithIndex:n] + byExtendingSelection:multi]; else [m_tableView deselectRow: n]; @@ -554,8 +611,8 @@ wxWidgetImplType* wxWidgetImpl::CreateListBox( wxWindowMac* wxpeer, wxListWidgetCocoaImpl* c = new wxListWidgetCocoaImpl( wxpeer, scrollview, tableview, ds ); // temporary hook for dnd - [tableview registerForDraggedTypes:[NSArray arrayWithObjects: - NSStringPboardType, NSFilenamesPboardType, NSTIFFPboardType, NSPICTPboardType, NSPDFPboardType, nil]]; + // [tableview registerForDraggedTypes:[NSArray arrayWithObjects: + // NSStringPboardType, NSFilenamesPboardType, (NSString*) kPasteboardTypeFileURLPromise, NSTIFFPboardType, NSPICTPboardType, NSPDFPboardType, nil]]; [ds setImplementation:c]; return c;