-typedef struct {
- unsigned short instruction;
- void (*function)();
-} ldefRec, *ldefPtr, **ldefHandle;
-
-extern "C"
-{
-static pascal void wxMacListDefinition( short message, Boolean isSelected, Rect *drawRect,
- Cell cell, short dataOffset, short dataLength,
- ListHandle listHandle ) ;
-}
-
-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;
- SInt32 savedPenMode;
- wxListBox* list;
- GetPort(&savePort);
- SetPort((**listHandle).port);
- grafPtr = (**listHandle).port ;
- // typecast our refCon
- list = (wxListBox*) GetControlReference( (ControlHandle) GetListRefCon(listHandle) );
-
- // Calculate the cell rect.
-
- switch( message ) {
- case lInitMsg:
- break;
-
- case lCloseMsg:
- break;
-
- case lDrawMsg:
- {
- const wxString text = list->m_stringArray[cell.v] ;
-
- // Save the current clip region, and set the clip region to the area we are about
- // to draw.
-
- savedClipRegion = NewRgn();
- GetClip( savedClipRegion );
- ClipRect( drawRect );
- EraseRect( drawRect );
-
-
- MoveTo(drawRect->left + 4 , drawRect->top + 10 );
- ::TextFont( kFontIDMonaco ) ;
- ::TextSize( 9 );
- ::TextFace( 0 ) ;
-
- DrawText(text, 0 , text.Length());
- // If the cell is hilited, do the hilite now. Paint the cell contents with the
- // appropriate QuickDraw transform mode.
-
- if( isSelected ) {
- savedPenMode = GetPortPenMode( grafPtr );
- SetPortPenMode( grafPtr, hilitetransfermode );
- PaintRect( drawRect );
- SetPortPenMode( grafPtr, savedPenMode );
- }
-
- // Restore the saved clip region.
-
- SetClip( savedClipRegion );
- DisposeRgn( savedClipRegion );
- }
- break;
- case lHiliteMsg:
-
- // Hilite or unhilite the cell. Paint the cell contents with the
- // appropriate QuickDraw transform mode.
-
- GetPort( &grafPtr );
- savedPenMode = GetPortPenMode( grafPtr );
- SetPortPenMode( grafPtr, hilitetransfermode );
- PaintRect( drawRect );
- SetPortPenMode( grafPtr, savedPenMode );
- break;
- default :
- break ;
- }
- SetPort(savePort);
-}
-
-extern "C" void MacDrawStringCell(Rect *cellRect, Cell lCell, ListHandle theList, long refCon) ;
-const short kwxMacListWithVerticalScrollbar = 128 ;
+ virtual void UpdateLine( int n ) = 0;
+
+ virtual void MacDelete( int n ) = 0;
+ virtual void MacInsert( int n, const wxString& item ) = 0;
+ virtual void MacInsert( int n, const wxArrayString& items ) = 0;
+ virtual void MacAppend( const wxString& item ) = 0;
+ virtual void MacSet( int n, const wxString& item ) = 0;
+ virtual void MacClear() = 0;
+ virtual void MacDeselectAll() = 0;
+ virtual void MacSetSelection( int n, bool select ) = 0;
+ virtual int MacGetSelection() const = 0;
+ virtual int MacGetSelections( wxArrayInt& aSelections ) const = 0;
+ virtual bool MacIsSelected( int n ) const = 0;
+ virtual void MacScrollTo( int n ) = 0;
+
+ wxListBox * GetPeer() const
+ { return (wxListBox*)m_peer; }
+};
+
+#if 0
+// In case we have to replace data browser ...
+// custom HIView-based implementation
+
+class wxMacCustomHIViewListControl : public wxMacListControl
+{
+public:
+ wxMacCustomHIViewListControl( wxListBox *peer, const wxPoint& pos, const wxSize& size, long style );
+ ~wxMacCustomHIViewListControl();
+
+ void MacDelete( int n );
+ void MacInsert( int n, const wxString& item );
+ void MacInsert( int n, const wxArrayString& items );
+ void MacAppend( const wxString& item );
+ void MacSet( int n, const wxString& item );
+ void MacClear();
+ void MacDeselectAll();
+ void MacSetSelection( int n, bool select );
+ int MacGetSelection() const;
+ int MacGetSelections( wxArrayInt& aSelections ) const;
+ bool MacIsSelected( int n ) const;
+ void MacScrollTo( int n );
+};
+#endif
+
+// DataBrowser-based implementation
+
+class wxMacDataBrowserListControl : public wxMacListControl
+{
+public:
+ wxMacDataBrowserListControl( wxListBox *peer, const wxPoint& pos, const wxSize& size, long style );
+ ~wxMacDataBrowserListControl();
+
+ void UpdateLine( int n );
+
+ void MacDelete( int n );
+ void MacInsert( int n, const wxString& item );
+ void MacInsert( int n, const wxArrayString& items );
+ void MacAppend( const wxString& item );
+ void MacSet( int n, const wxString& item );
+ void MacClear();
+ void MacDeselectAll();
+ void MacSetSelection( int n, bool select );
+ int MacGetSelection() const;
+ int MacGetSelections( wxArrayInt& aSelections ) const;
+ bool MacIsSelected( int n ) const;
+ void MacScrollTo( int n );
+
+ virtual OSStatus SetSelectionFlags( DataBrowserSelectionFlags );
+ virtual OSStatus AddListViewColumn( DataBrowserListViewColumnDesc *columnDesc,
+ DataBrowserTableViewColumnIndex position );
+ virtual OSStatus AutoSizeListViewColumns();
+ virtual OSStatus SetHasScrollBars( bool horiz, bool vert );
+ virtual OSStatus SetTableViewHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle );
+ virtual OSStatus SetListViewHeaderBtnHeight( UInt16 height );
+ virtual OSStatus SetCallbacks( const DataBrowserCallbacks *callbacks );
+ virtual OSStatus UpdateItems( DataBrowserItemID container, UInt32 numItems,
+ const DataBrowserItemID *items,
+ DataBrowserPropertyID preSortProperty,
+ DataBrowserPropertyID propertyID );
+ virtual OSStatus AddItems( DataBrowserItemID container, UInt32 numItems,
+ const DataBrowserItemID *items,
+ DataBrowserPropertyID preSortProperty );
+ virtual OSStatus RemoveItems( DataBrowserItemID container, UInt32 numItems,
+ const DataBrowserItemID *items,
+ DataBrowserPropertyID preSortProperty );
+ virtual OSStatus RevealItem( DataBrowserItemID item,
+ DataBrowserPropertyID propertyID,
+ DataBrowserRevealOptions options );
+ virtual OSStatus GetSelectionAnchor( DataBrowserItemID *first, DataBrowserItemID *last ) const;
+ virtual bool IsItemSelected( DataBrowserItemID item ) const;
+ virtual OSStatus SetSelectedItems( UInt32 numItems,
+ const DataBrowserItemID *items,
+ DataBrowserSetOption operation );
+
+private:
+ // as we are getting the same events for human and API selection we have to suppress
+ // events in the latter case
+ bool MacSuppressSelection( bool suppress );
+ bool MacIsSelectionSuppressed() const { return m_suppressSelection; }
+
+ bool m_suppressSelection;
+
+#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
+};