-DataBrowserItemDataUPP gDataBrowserItemDataUPP = NULL ;
-DataBrowserItemNotificationUPP gDataBrowserItemNotificationUPP = NULL ;
-DataBrowserDrawItemUPP gDataBrowserDrawItemUPP = NULL ;
-
-
-#if TARGET_API_MAC_OSX
-static pascal void DataBrowserItemNotificationProc(ControlRef browser, DataBrowserItemID itemID,
- DataBrowserItemNotification message, DataBrowserItemDataRef itemData)
-#else
-static pascal void DataBrowserItemNotificationProc(ControlRef browser, DataBrowserItemID itemID,
- DataBrowserItemNotification message)
-#endif
-{
- long ref = GetControlReference( browser ) ;
- if ( ref )
- {
- wxListBox* list = wxDynamicCast( (wxObject*) ref , wxListBox ) ;
- int i = itemID - 1 ;
- if (i >= 0 && i < list->GetCount() )
- {
- bool trigger = false ;
- wxCommandEvent event( wxEVT_COMMAND_LISTBOX_SELECTED, list->GetId() );
- switch ( message )
- {
- case kDataBrowserItemDeselected :
- if ( list->HasMultipleSelection() )
- trigger = !list->MacIsSelectionSuppressed() ;
- break ;
-
- case kDataBrowserItemSelected :
- trigger = !list->MacIsSelectionSuppressed() ;
- break ;
-
- case kDataBrowserItemDoubleClicked :
- event.SetEventType( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED ) ;
- trigger = true ;
- break ;
-
- default :
- break ;
- }
-
- if ( trigger )
- {
- event.SetEventObject( list );
- if ( list->HasClientObjectData() )
- event.SetClientObject( list->GetClientObject( i ) );
- else if ( list->HasClientUntypedData() )
- event.SetClientData( list->GetClientData( i ) );
- event.SetString( list->GetString( i ) );
- event.SetInt( i ) ;
- event.SetExtraLong( list->HasMultipleSelection() ? message == kDataBrowserItemSelected : true );
- wxPostEvent( list->GetEventHandler() , event ) ;
- // direct notification is not always having the listbox GetSelection() having in synch with event
- // list->GetEventHandler()->ProcessEvent(event) ;
- }
- }
- }
-}
-
-static pascal OSStatus ListBoxGetSetItemData(ControlRef browser,
- DataBrowserItemID itemID, DataBrowserPropertyID property,
- DataBrowserItemDataRef itemData, Boolean changeValue)
-{
- OSStatus err = errDataBrowserPropertyNotSupported;
-
- if ( ! changeValue )
- {
- switch (property)
- {
- case kTextColumnId:
- {
- long ref = GetControlReference( browser ) ;
- if ( ref )
- {
- wxListBox* list = wxDynamicCast( (wxObject*) ref , wxListBox ) ;
- int i = itemID - 1 ;
- if (i >= 0 && i < list->GetCount() )
- {
- wxMacCFStringHolder cf( list->GetString( i ) , list->GetFont().GetEncoding() ) ;
- verify_noerr( ::SetDataBrowserItemDataText( itemData , cf ) ) ;
- err = noErr ;
- }
- }
- }
- break;
-
- default:
- break;
- }
- }
-
- return err;
-}
-
-static pascal void ListBoxDrawProc( ControlRef browser , DataBrowserItemID item , DataBrowserPropertyID property ,
- DataBrowserItemState itemState , const Rect *itemRect , SInt16 depth , Boolean isColorDevice )
-{
- CFStringRef cfString;
- ThemeDrawingState themeState ;
- long systemVersion;
-
- GetThemeDrawingState( &themeState ) ;
- cfString = CFStringCreateWithFormat( NULL, NULL, CFSTR("Row %d"), item );
-
- // In this sample we handle the "selected" state; all others fall through to our "active" state
- if ( itemState == kDataBrowserItemIsSelected )
- {
- ThemeBrush colorBrushID;
-
- Gestalt( gestaltSystemVersion, &systemVersion );
-
- // TODO: switch over to wxSystemSettingsNative::GetColour() when kThemeBrushSecondaryHighlightColor is incorporated
- // Panther DB starts using kThemeBrushSecondaryHighlightColor for inactive browser hilighting
- if ( (systemVersion >= 0x00001030) && !IsControlActive( browser ) )
- colorBrushID = kThemeBrushSecondaryHighlightColor;
- else
- colorBrushID = kThemeBrushPrimaryHighlightColor;
-
- // First paint the hilite rect, then the text on top
- SetThemePen( colorBrushID, 32, true );
- PaintRect( itemRect );
- SetThemeDrawingState( themeState , false ) ;
- }
-
- DrawThemeTextBox( cfString, kThemeApplicationFont, kThemeStateActive, true, itemRect, teFlushDefault, NULL );
- SetThemeDrawingState( themeState , true ) ;
-
- if ( cfString != NULL )
- CFRelease( cfString );
-}