IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl)
BEGIN_EVENT_TABLE(wxListBox, wxControl)
- EVT_SIZE( wxListBox::OnSize )
+ EVT_SIZE( wxListBox::OnSize )
+ EVT_CHAR( wxListBox::OnChar )
END_EVENT_TABLE()
#endif
#include "wx/mac/uma.h"
+#if PRAGMA_STRUCT_ALIGN
+ #pragma options align=mac68k
+#elif PRAGMA_STRUCT_PACKPUSH
+ #pragma pack(push, 2)
+#elif PRAGMA_STRUCT_PACK
+ #pragma pack(2)
+#endif
typedef struct {
unsigned short instruction;
void (*function)();
} ldefRec, *ldefPtr, **ldefHandle;
+#if PRAGMA_STRUCT_ALIGN
+ #pragma options align=reset
+#elif PRAGMA_STRUCT_PACKPUSH
+ #pragma pack(pop)
+#elif PRAGMA_STRUCT_PACK
+ #pragma pack()
+#endif
+
extern "C"
{
static pascal void wxMacListDefinition( short message, Boolean isSelected, Rect *drawRect,
Cell cell, short dataOffset, short dataLength,
ListHandle listHandle )
{
- FontInfo fontInfo;
GrafPtr savePort;
GrafPtr grafPtr;
RgnHandle savedClipRegion;
Size asize;
- CreateListBoxControl( parent->MacGetRootWindow(), &bounds, false, 0, 1, false, true,
- kwxMacListItemHeight, kwxMacListItemHeight, false, &listDef, &m_macControl );
+ CreateListBoxControl( MAC_WXHWND(parent->MacGetRootWindow()), &bounds, false, 0, 1, false, true,
+ kwxMacListItemHeight, kwxMacListItemHeight, false, &listDef, (ControlRef *)&m_macControl );
GetControlData( (ControlHandle) m_macControl, kControlNoPart, kControlListBoxListHandleTag,
sizeof(ListHandle), (Ptr) &m_macList, &asize);
#else
long result ;
-
+ wxStAppResource resload ;
m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false ,
kwxMacListWithVerticalScrollbar , 0 , 0,
kControlListBoxProc , (long) this ) ;
#if TARGET_CARBON
Rect bounds ;
GetControlBounds( (ControlHandle) m_macControl , &bounds ) ;
- ControlRef control = GetListVerticalScrollBar( m_macList ) ;
+ ControlRef control = GetListVerticalScrollBar( (ListHandle)m_macList ) ;
if ( control )
{
Rect scrollbounds ;
delete GetClientObject(N);
}
#endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
- m_stringArray.Remove( N ) ;
+ m_stringArray.RemoveAt( N ) ;
m_dataArray.RemoveAt( N ) ;
m_noItems --;
}
if ( s.Left(1) == "*" && s.Length() > 1 )
{
+ s = st ;
s.MakeLower() ;
for ( int i = 0 ; i < m_noItems ; ++i )
{
void wxListBox::SetupColours()
{
- SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW));
+ SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
SetForegroundColour(GetParent()->GetForegroundColour());
}
Cell cell = { 0 , 0 } ;
if ( ! (m_windowStyle & wxLB_MULTIPLE) )
{
- if ( LGetSelect( true , &cell , (ListHandle)m_macList ) )
- {
- LSetSelect( false , cell , (ListHandle)m_macList ) ;
- }
+ if ( LGetSelect( true , &cell , (ListHandle)m_macList ) )
+ {
+ LSetSelect( false , cell , (ListHandle)m_macList ) ;
+ }
}
cell.v = n ;
Point pt;
#if TARGET_CARBON
- GetListCellSize(m_macList, &pt);
+ GetListCellSize((ListHandle)m_macList, &pt);
#else
pt = (**(ListHandle)m_macList).cellSize ;
#endif
{
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, m_windowId);
event.SetEventObject( this );
- GetEventHandler()->ProcessEvent(event) ;
+ GetEventHandler()->ProcessEvent(event) ;
+}
+
+static long sLastTypeIn = 0 ;
+
+void wxListBox::OnChar(wxKeyEvent& event)
+{
+ EventRecord *ev = (EventRecord*) (wxTheApp->MacGetCurrentEvent() ) ;
+ short keycode ;
+ short keychar ;
+ keychar = short(ev->message & charCodeMask);
+ keycode = short(ev->message & keyCodeMask) >> 8 ;
+ if ( event.KeyCode() == WXK_SPACE )
+ {
+ wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId);
+ event.SetEventObject( this );
+
+ wxArrayInt aSelections;
+ int n, count = GetSelections(aSelections);
+ if ( count > 0 )
+ {
+ n = aSelections[0];
+ if ( HasClientObjectData() )
+ event.SetClientObject( GetClientObject(n) );
+ else if ( HasClientUntypedData() )
+ event.SetClientData( GetClientData(n) );
+ event.SetString( GetString(n) );
+ }
+ else
+ {
+ n = -1;
+ }
+
+ event.m_commandInt = n;
+
+ GetEventHandler()->ProcessEvent(event);
+ }
+ else if ( event.KeyCode() == WXK_DOWN || event.KeyCode() == WXK_UP )
+ {
+ ::HandleControlKey( (ControlHandle) m_macControl , keycode , keychar , ev->modifiers ) ;
+ }
+ else
+ {
+ if ( ev->when > m_lastTypeIn + 60 )
+ {
+ m_typeIn = "" ;
+ }
+ m_lastTypeIn = ev->when ;
+ m_typeIn += (char) event.KeyCode() ;
+ int line = FindString("*"+m_typeIn+"*") ;
+ if ( line >= 0 )
+ {
+ SetSelection(line) ;
+ }
+ }
}
+