]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/cocoa/listbox.mm
wiring OnInit on osx to a later point in event processing
[wxWidgets.git] / src / osx / cocoa / listbox.mm
index 4b10d40656059b215e972d825b4905f0237e6945..5bfef6d04703845b727c3b93345654e28628f771 100644 (file)
@@ -303,7 +303,7 @@ protected:
         wxListBox *list = static_cast<wxListBox*> ( impl->GetWXPeer());
         wxCHECK_RET( list != NULL , wxT("Listbox expected"));
         
-        wxCommandEvent event( wxEVT_COMMAND_LISTBOX_SELECTED, list->GetId() );
+        wxCommandEvent event( wxEVT_LISTBOX, list->GetId() );
         
         if ((row < 0) || (row > (int) list->GetCount()))  // OS X can select an item below the last item
             return;
@@ -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<wxListBox*> ( 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<wxListBox*> ( 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];
@@ -555,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;