wxItemContainerImmutable::FindString unified.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35742 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1,20 +1,18 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: cocoa/combobox.mm
|
||||
// Name: src/cocoa/combobox.mm
|
||||
// Purpose: wxComboBox
|
||||
// Author: Ryan Norton
|
||||
// Author: Ryan Norton
|
||||
// Modified by:
|
||||
// Created: 2005/02/16
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2003 David Elliott
|
||||
// Licence: wxWidgets licence
|
||||
// Licence: wxWidgets licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// #include "wx/wxprec.h"
|
||||
|
||||
//
|
||||
// Impl notes:
|
||||
// There is no custom data source because doing so unnecessarily sacrifices
|
||||
// some native autocompletion behavior (we would have to make our own -
|
||||
// some native autocompletion behavior (we would have to make our own -
|
||||
// the SimpleComboBox sample does so in the developer folder that
|
||||
// comes with OSX). One reason you might want this would be to have
|
||||
// only one array or be able to display numbers returned by an NSNumber
|
||||
@@ -28,9 +26,9 @@
|
||||
// doWxEvent is really hackish... but since there's only one event...
|
||||
//
|
||||
// Ideas for future improvement - other notes:
|
||||
// Combox w/o wxCB_DROPDOWN doesn't seem to be implementable
|
||||
//wxCB_READONLY Same as wxCB_DROPDOWN but only the strings specified as the combobox choices can be selected, it is impossible to select (even from a program) a string which is not in the choices list.
|
||||
//wxCB_SORT is possible with data source
|
||||
// Combox w/o wxCB_DROPDOWN doesn't seem to be implementable
|
||||
//wxCB_READONLY Same as wxCB_DROPDOWN but only the strings specified as the combobox choices can be selected, it is impossible to select (even from a program) a string which is not in the choices list.
|
||||
//wxCB_SORT is possible with data source
|
||||
//
|
||||
// setIntercellSpacing:/setItemHeight: to autoadjust to number of inserted items?
|
||||
//
|
||||
@@ -55,7 +53,7 @@
|
||||
NSString *lowercasePrefix = [prefix lowercaseString];
|
||||
NSEnumerator *stringEnum = [genres objectEnumerator];
|
||||
while ((string = [stringEnum nextObject])) {
|
||||
if ([[string lowercaseString] hasPrefix: lowercasePrefix]) return string;
|
||||
if ([[string lowercaseString] hasPrefix: lowercasePrefix]) return string;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
@@ -68,17 +66,6 @@
|
||||
}
|
||||
*/
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: cocoa/NSComboBox.mm
|
||||
// Purpose: wxCocoaNSComboBox
|
||||
// Author: Ryan Norton
|
||||
// Modified by:
|
||||
// Created: 2005/02/16
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) 2003 David Elliott
|
||||
// Licence: wxWidgets licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
@@ -111,7 +98,7 @@ void wxCocoaNSComboBox::AssociateNSComboBox(WX_NSComboBox cocoaNSComboBox)
|
||||
if(cocoaNSComboBox)
|
||||
{
|
||||
sm_cocoaHash.insert(wxCocoaNSComboBoxHash::value_type(cocoaNSComboBox,this));
|
||||
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:(id)cocoaNSComboBox selector:@selector(comboBoxSelectionDidChange:) name:@"NSComboBoxSelectionDidChangeNotification" object:cocoaNSComboBox];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:(id)cocoaNSComboBox selector:@selector(comboBoxSelectionDidChange:) name:@"NSComboBoxSelectionIsChangingNotification" object:cocoaNSComboBox];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:(id)cocoaNSComboBox selector:@selector(comboBoxSelectionDidChange:) name:@"NSComboBoxWillDismissNotification" object:cocoaNSComboBox];
|
||||
@@ -211,7 +198,7 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID winid,
|
||||
wxAutoNSAutoreleasePool pool;
|
||||
if(!CreateControl(parent,winid,pos,size,style,validator,name))
|
||||
return false;
|
||||
|
||||
|
||||
m_cocoaNSView = NULL;
|
||||
SetNSComboBox([[wxPoserNSComboBox alloc] initWithFrame:MakeDefaultNSRect(size)]);
|
||||
[m_cocoaNSView release];
|
||||
@@ -223,9 +210,9 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID winid,
|
||||
|
||||
for(int i = 0; i < n; ++i)
|
||||
wxComboBox::DoAppend(choices[i]);
|
||||
|
||||
|
||||
[GetNSComboBox() setCompletes:true]; //autocomplete :)
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -279,22 +266,29 @@ int wxComboBox::GetCount() const
|
||||
}
|
||||
|
||||
wxString wxComboBox::GetString(int nIndex) const
|
||||
{ return wxStringWithNSString([GetNSComboBox() itemObjectValueAtIndex:nIndex]); }
|
||||
{
|
||||
return wxStringWithNSString([GetNSComboBox() itemObjectValueAtIndex:nIndex]);
|
||||
}
|
||||
|
||||
void wxComboBox::SetString(int nIndex, const wxString& szString)
|
||||
{
|
||||
{
|
||||
wxAutoNSAutoreleasePool pool;
|
||||
//FIXME: There appears to be no "set item data" method - maybe
|
||||
//an assignment would work?
|
||||
[GetNSComboBox() removeItemAtIndex:nIndex];
|
||||
[GetNSComboBox() insertItemWithObjectValue:wxNSStringWithWxString(szString) atIndex:nIndex];
|
||||
[GetNSComboBox() insertItemWithObjectValue:wxNSStringWithWxString(szString) atIndex:nIndex];
|
||||
}
|
||||
|
||||
int wxComboBox::FindString(const wxString& szItem) const
|
||||
{ return [GetNSComboBox() indexOfItemWithObjectValue:wxNSStringWithWxString(szItem)]; }
|
||||
int wxComboBox::FindString(const wxString& szItem, bool bCase) const
|
||||
{
|
||||
// FIXME: use wxItemContainerImmutable::FindString for bCase parameter
|
||||
return [GetNSComboBox() indexOfItemWithObjectValue:wxNSStringWithWxString(szItem)];
|
||||
}
|
||||
|
||||
int wxComboBox::GetSelection() const
|
||||
{ return [GetNSComboBox() indexOfSelectedItem]; }
|
||||
{
|
||||
return [GetNSComboBox() indexOfSelectedItem];
|
||||
}
|
||||
|
||||
int wxComboBox::DoAppend(const wxString& szItem)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user