common event code

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58077 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2009-01-13 18:19:42 +00:00
parent 9d33840bab
commit 2126732187
4 changed files with 78 additions and 22 deletions

View File

@@ -59,6 +59,8 @@ class wxListWidgetCocoaImpl;
- (void)setImplementation: (wxListWidgetCocoaImpl *) theImplementation;
- (wxListWidgetCocoaImpl*) implementation;
- (void)clickedAction: (id) sender;
- (void)doubleClickedAction: (id) sender;
@end
@@ -282,6 +284,47 @@ protected:
return impl;
}
- (id) init
{
[super init];
impl = NULL;
[self setTarget: self];
[self setAction: @selector(clickedAction:)];
[self setDoubleAction: @selector(doubleClickedAction:)];
return self;
}
- (void) clickedAction: (id) sender
{
if ( impl )
{
wxListBox *list = static_cast<wxListBox*> ( impl->GetWXPeer());
wxCHECK_RET( list != NULL , wxT("Listbox expected"));
wxCommandEvent event( wxEVT_COMMAND_LISTBOX_SELECTED, list->GetId() );
int sel = [self clickedRow];
if ((sel < 0) || (sel > (int) list->GetCount())) // OS X can select an item below the last item (why?)
return;
list->HandleLineEvent( sel, false );
}
}
- (void) doubleClickedAction: (id) sender
{
if ( impl )
{
wxListBox *list = static_cast<wxListBox*> ( impl->GetWXPeer());
wxCHECK_RET( list != NULL , wxT("Listbox expected"));
int sel = [self clickedRow];
if ((sel < 0) || (sel > (int) list->GetCount())) // OS X can select an item below the last item (why?)
return;
list->HandleLineEvent( sel, true );
}
}
@end
@@ -428,17 +471,27 @@ void wxListWidgetCocoaImpl::ListSetSelection( unsigned int n, bool select, bool
int wxListWidgetCocoaImpl::ListGetSelection() const
{
return 0;
return [m_tableView selectedRow];
}
int wxListWidgetCocoaImpl::ListGetSelections( wxArrayInt& aSelections ) const
{
return 0;
aSelections.Empty();
int count = ListGetCount();
for ( int i = 0; i < count; ++i)
{
if ([m_tableView isRowSelected:count])
aSelections.Add(i);
}
return aSelections.Count();
}
bool wxListWidgetCocoaImpl::ListIsSelected( unsigned int n ) const
{
return false;
return [m_tableView isRowSelected:n];
}
// display