]> git.saurik.com Git - wxWidgets.git/blob - src/osx/carbon/listbox.cpp
Added missing RTTI
[wxWidgets.git] / src / osx / carbon / listbox.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/carbon/listbox.cpp
3 // Purpose: wxListBox
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // RCS-ID: $Id$
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/wxprec.h"
13
14 #if wxUSE_LISTBOX
15
16 #include "wx/listbox.h"
17
18 #ifndef WX_PRECOMP
19 #include "wx/log.h"
20 #include "wx/intl.h"
21 #include "wx/utils.h"
22 #include "wx/settings.h"
23 #include "wx/arrstr.h"
24 #include "wx/dcclient.h"
25 #endif
26
27 #include "wx/osx/private.h"
28
29 // ============================================================================
30 // list box control implementation
31 // ============================================================================
32
33 wxWidgetImplType* wxWidgetImpl::CreateListBox( wxWindowMac* wxpeer,
34 wxWindowMac* WXUNUSED(parent),
35 wxWindowID WXUNUSED(id),
36 const wxPoint& pos,
37 const wxSize& size,
38 long style,
39 long WXUNUSED(extraStyle))
40 {
41 wxMacDataBrowserListControl* control = new wxMacDataBrowserListControl( wxpeer, pos, size, style );
42 // TODO CHECK control->SetClientDataType( m_clientDataItemsType );
43 return control;
44 }
45
46 int wxMacDataBrowserListControl::DoListHitTest(const wxPoint& inpoint) const
47 {
48 OSStatus err;
49
50 // There are few reasons why this is complicated:
51 // 1) There is no native HitTest function for Mac
52 // 2) GetDataBrowserItemPartBounds only works on visible items
53 // 3) We can't do it through GetDataBrowserTableView[Item]RowHeight
54 // because what it returns is basically inaccurate in the context
55 // of the coordinates we want here, but we use this as a guess
56 // for where the first visible item lies
57
58 wxPoint point = inpoint;
59
60 // get column property ID (req. for call to itempartbounds)
61 DataBrowserTableViewColumnID colId = 0;
62 err = GetDataBrowserTableViewColumnProperty(GetControlRef(), 0, &colId);
63 wxCHECK_MSG(err == noErr, wxNOT_FOUND, wxT("Unexpected error from GetDataBrowserTableViewColumnProperty"));
64
65 // OK, first we need to find the first visible item we have -
66 // this will be the "low" for our binary search. There is no real
67 // easy way around this, as we will need to do a SLOW linear search
68 // until we find a visible item, but we can do a cheap calculation
69 // via the row height to speed things up a bit
70 UInt32 scrollx, scrolly;
71 err = GetDataBrowserScrollPosition(GetControlRef(), &scrollx, &scrolly);
72 wxCHECK_MSG(err == noErr, wxNOT_FOUND, wxT("Unexpected error from GetDataBrowserScrollPosition"));
73
74 UInt16 height;
75 err = GetDataBrowserTableViewRowHeight(GetControlRef(), &height);
76 wxCHECK_MSG(err == noErr, wxNOT_FOUND, wxT("Unexpected error from GetDataBrowserTableViewRowHeight"));
77
78 wxListBox *list = wxDynamicCast( GetWXPeer() , wxListBox );
79
80 // these indices are 0-based, as usual, so we need to add 1 to them when
81 // passing them to data browser functions which use 1-based indices
82 int low = scrolly / height,
83 high = list->GetCount() - 1;
84
85 // search for the first visible item (note that the scroll guess above
86 // is the low bounds of where the item might lie so we only use that as a
87 // starting point - we should reach it within 1 or 2 iterations of the loop)
88 while ( low <= high )
89 {
90 Rect bounds;
91 err = GetDataBrowserItemPartBounds(
92 GetControlRef(), low + 1, colId,
93 kDataBrowserPropertyEnclosingPart,
94 &bounds); // note +1 to translate to Mac ID
95 if ( err == noErr )
96 break;
97
98 // errDataBrowserItemNotFound is expected as it simply means that the
99 // item is not currently visible -- but other errors are not
100 wxCHECK_MSG( err == errDataBrowserItemNotFound, wxNOT_FOUND,
101 wxT("Unexpected error from GetDataBrowserItemPartBounds") );
102
103 low++;
104 }
105
106 // NOW do a binary search for where the item lies, searching low again if
107 // we hit an item that isn't visible
108 while ( low <= high )
109 {
110 int mid = (low + high) / 2;
111
112 Rect bounds;
113 err = GetDataBrowserItemPartBounds(
114 GetControlRef(), mid + 1, colId,
115 kDataBrowserPropertyEnclosingPart,
116 &bounds); //note +1 to trans to mac id
117 wxCHECK_MSG( err == noErr || err == errDataBrowserItemNotFound,
118 wxNOT_FOUND,
119 wxT("Unexpected error from GetDataBrowserItemPartBounds") );
120
121 if ( err == errDataBrowserItemNotFound )
122 {
123 // item not visible, attempt to find a visible one
124 // search lower
125 high = mid - 1;
126 }
127 else // visible item, do actual hitttest
128 {
129 // if point is within the bounds, return this item (since we assume
130 // all x coords of items are equal we only test the x coord in
131 // equality)
132 if ((point.x >= bounds.left && point.x <= bounds.right) &&
133 (point.y >= bounds.top && point.y <= bounds.bottom) )
134 {
135 // found!
136 return mid;
137 }
138
139 if ( point.y < bounds.top )
140 // index(bounds) greater than key(point)
141 high = mid - 1;
142 else
143 // index(bounds) less than key(point)
144 low = mid + 1;
145 }
146 }
147
148 return wxNOT_FOUND;
149 }
150
151 // ============================================================================
152 // data browser based implementation
153 // ============================================================================
154
155 wxMacListBoxItem::wxMacListBoxItem()
156 :wxMacDataItem()
157 {
158 }
159
160 wxMacListBoxItem::~wxMacListBoxItem()
161 {
162 }
163
164 OSStatus wxMacListBoxItem::GetSetData(wxMacDataItemBrowserControl *owner ,
165 DataBrowserPropertyID property,
166 DataBrowserItemDataRef itemData,
167 bool changeValue )
168 {
169 wxMacDataBrowserListControl *lb = wxDynamicCast(owner,wxMacDataBrowserListControl);
170 OSStatus err = errDataBrowserPropertyNotSupported;
171 if ( !changeValue )
172 {
173 if ( property >= kMinColumnId )
174 {
175 wxMacDataBrowserColumn* col = lb->GetColumnFromProperty( property );
176 unsigned int n = owner->GetLineFromItem( this );
177 wxListBox *list = wxDynamicCast( owner->GetWXPeer() , wxListBox );
178 wxMacDataBrowserCellValue valueholder(itemData);
179 list->GetValueCallback( n , col, valueholder );
180
181 err = noErr;
182 }
183 else
184 {
185 if ( property == kDataBrowserItemIsEditableProperty )
186 {
187 DataBrowserPropertyID propertyToEdit ;
188 GetDataBrowserItemDataProperty( itemData, &propertyToEdit );
189 wxMacDataBrowserColumn* col = lb->GetColumnFromProperty( propertyToEdit );
190
191 verify_noerr(SetDataBrowserItemDataBooleanValue( itemData, col->IsEditable() ));
192 err = noErr;
193 }
194
195 }
196
197 }
198 else
199 {
200 if ( property >= kMinColumnId )
201 {
202 wxMacDataBrowserColumn* col = lb->GetColumnFromProperty( property );
203
204 unsigned int n = owner->GetLineFromItem( this );
205 wxListBox *list = wxDynamicCast( owner->GetWXPeer() , wxListBox );
206 wxMacDataBrowserCellValue valueholder(itemData);
207 list->SetValueCallback( n , col, valueholder );
208
209 /*
210 // we have to change this behind the back, since Check() would be triggering another update round
211 bool newVal = !m_isChecked;
212 verify_noerr(SetDataBrowserItemDataButtonValue( itemData, newVal ? kThemeButtonOn : kThemeButtonOff ));
213 m_isChecked = newVal;
214 err = noErr;
215
216 wxCommandEvent event( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, checklist->GetId() );
217 event.SetInt( owner->GetLineFromItem( this ) );
218 event.SetEventObject( checklist );
219 checklist->HandleWindowEvent( event );
220
221 */
222 err = noErr;
223 }
224 }
225
226 // call inherited if not ours
227 if ( err == errDataBrowserPropertyNotSupported )
228 {
229 err = wxMacDataItem::GetSetData(owner, property, itemData, changeValue);
230 }
231
232 return err;
233 }
234
235 void wxMacListBoxItem::Notification(wxMacDataItemBrowserControl *owner ,
236 DataBrowserItemNotification message,
237 DataBrowserItemDataRef WXUNUSED(itemData) ) const
238 {
239 wxMacDataBrowserListControl *lb = wxDynamicCast(owner,wxMacDataBrowserListControl);
240
241 // we want to depend on as little as possible to make sure tear-down of controls is safe
242
243 if ( message == kDataBrowserItemRemoved)
244 {
245 delete this;
246 return;
247 }
248
249 wxListBox *list = wxDynamicCast( lb->GetWXPeer() , wxListBox );
250 wxCHECK_RET( list != NULL , wxT("Listbox expected"));
251
252 if (message == kDataBrowserItemDoubleClicked)
253 {
254 unsigned int n = owner->GetLineFromItem( this );
255 list->HandleLineEvent( n, true );
256 return;
257 }
258 }
259
260 IMPLEMENT_DYNAMIC_CLASS( wxMacDataBrowserListControl , wxMacDataItemBrowserControl )
261
262 wxMacDataBrowserListControl::wxMacDataBrowserListControl( wxWindow *peer, const wxPoint& pos, const wxSize& size, long style)
263 : wxMacDataItemBrowserControl( peer, pos, size, style )
264 {
265 m_nextColumnId = 0 ;
266
267 OSStatus err = noErr;
268 m_clientDataItemsType = wxClientData_None;
269 if ( style & wxLB_SORT )
270 m_sortOrder = SortOrder_Text_Ascending;
271
272 DataBrowserSelectionFlags options = kDataBrowserDragSelect;
273 if ( style & wxLB_MULTIPLE )
274 {
275 options |= kDataBrowserAlwaysExtendSelection | kDataBrowserCmdTogglesSelection;
276 }
277 else if ( style & wxLB_EXTENDED )
278 {
279 options |= kDataBrowserCmdTogglesSelection;
280 }
281 else
282 {
283 options |= kDataBrowserSelectOnlyOne;
284 }
285 err = SetSelectionFlags( options );
286 verify_noerr( err );
287
288 DataBrowserListViewColumnDesc columnDesc;
289 columnDesc.headerBtnDesc.titleOffset = 0;
290 columnDesc.headerBtnDesc.version = kDataBrowserListViewLatestHeaderDesc;
291
292 columnDesc.headerBtnDesc.btnFontStyle.flags =
293 kControlUseFontMask | kControlUseJustMask;
294
295 columnDesc.headerBtnDesc.btnContentInfo.contentType = kControlNoContent;
296 columnDesc.headerBtnDesc.btnFontStyle.just = teFlushDefault;
297 columnDesc.headerBtnDesc.btnFontStyle.font = kControlFontViewSystemFont;
298 columnDesc.headerBtnDesc.btnFontStyle.style = normal;
299 columnDesc.headerBtnDesc.titleString = NULL;
300 /*
301 columnDesc.headerBtnDesc.minimumWidth = 0;
302 columnDesc.headerBtnDesc.maximumWidth = 10000;
303
304 columnDesc.propertyDesc.propertyID = kTextColumnId;
305 columnDesc.propertyDesc.propertyType = kDataBrowserTextType;
306 columnDesc.propertyDesc.propertyFlags = kDataBrowserTableViewSelectionColumn;
307 columnDesc.propertyDesc.propertyFlags |= kDataBrowserListViewTypeSelectColumn;
308
309 verify_noerr( AddColumn( &columnDesc, kDataBrowserListViewAppendColumn ) );
310 */
311 columnDesc.headerBtnDesc.minimumWidth = 0;
312 columnDesc.headerBtnDesc.maximumWidth = 0;
313 columnDesc.propertyDesc.propertyID = kNumericOrderColumnId;
314 columnDesc.propertyDesc.propertyType = kDataBrowserPropertyRelevanceRankPart;
315 columnDesc.propertyDesc.propertyFlags = kDataBrowserTableViewSelectionColumn;
316 columnDesc.propertyDesc.propertyFlags |= kDataBrowserListViewTypeSelectColumn;
317
318 verify_noerr( AddColumn( &columnDesc, kDataBrowserListViewAppendColumn ) );
319
320 /*
321 SetDataBrowserSortProperty( m_controlRef , kTextColumnId);
322 if ( m_sortOrder == SortOrder_Text_Ascending )
323 {
324 SetDataBrowserSortProperty( m_controlRef , kTextColumnId);
325 SetDataBrowserSortOrder( m_controlRef , kDataBrowserOrderIncreasing);
326 }
327 else
328 */
329 {
330 SetDataBrowserSortProperty( m_controlRef , kNumericOrderColumnId);
331 SetDataBrowserSortOrder( m_controlRef , kDataBrowserOrderIncreasing);
332 }
333
334 verify_noerr( AutoSizeColumns() );
335 verify_noerr( SetHiliteStyle(kDataBrowserTableViewFillHilite ) );
336 verify_noerr( SetHeaderButtonHeight( 0 ) );
337 err = SetHasScrollBars( (style & wxHSCROLL) != 0 , true );
338 #if 0
339 // shouldn't be necessary anymore under 10.2
340 GetPeer()->SetData( kControlNoPart, kControlDataBrowserIncludesFrameAndFocusTag, (Boolean)false );
341 GetPeer()->SetNeedsFocusRect( true );
342 #endif
343 }
344
345 wxMacDataBrowserListControl::~wxMacDataBrowserListControl()
346 {
347 }
348
349 void wxMacDataBrowserListControl::ItemNotification(
350 DataBrowserItemID itemID,
351 DataBrowserItemNotification message,
352 DataBrowserItemDataRef itemData)
353 {
354 wxListBox *list = wxDynamicCast( GetWXPeer() , wxListBox );
355 wxCHECK_RET( list != NULL , wxT("Listbox expected"));
356
357 if (list->HasMultipleSelection() && (message == kDataBrowserSelectionSetChanged) && (!list->MacGetBlockEvents()))
358 {
359 list->CalcAndSendEvent();
360 return;
361 }
362
363 if ((message == kDataBrowserSelectionSetChanged) && (!list->MacGetBlockEvents()))
364 {
365 wxCommandEvent event( wxEVT_COMMAND_LISTBOX_SELECTED, list->GetId() );
366
367 int sel = list->GetSelection();
368 if ((sel < 0) || (sel > (int) list->GetCount())) // OS X can select an item below the last item (why?)
369 return;
370 list->HandleLineEvent( sel, false );
371 return;
372 }
373
374 // call super for item level(wxMacDataItem->Notification) callback processing
375 wxMacDataItemBrowserControl::ItemNotification( itemID, message, itemData);
376 }
377
378
379 /*
380 wxWindow * wxMacDataBrowserListControl::GetPeer() const
381 {
382 return wxDynamicCast( wxMacControl::GetWX() , wxWindow );
383 }
384 */
385
386 //
387 // List Methods
388 //
389
390 wxMacDataBrowserColumn* wxMacDataBrowserListControl::DoInsertColumn( unsigned int pos, DataBrowserPropertyID property,
391 const wxString& title, bool editable,
392 DataBrowserPropertyType colType, SInt16 just, int width )
393 {
394 DataBrowserListViewColumnDesc columnDesc;
395 columnDesc.headerBtnDesc.titleOffset = 0;
396 columnDesc.headerBtnDesc.version = kDataBrowserListViewLatestHeaderDesc;
397
398 columnDesc.headerBtnDesc.btnFontStyle.flags =
399 kControlUseFontMask | kControlUseJustMask;
400
401 columnDesc.headerBtnDesc.btnContentInfo.contentType = kControlContentTextOnly;
402 columnDesc.headerBtnDesc.btnFontStyle.just = just;
403 columnDesc.headerBtnDesc.btnFontStyle.font = kControlFontViewSystemFont;
404 columnDesc.headerBtnDesc.btnFontStyle.style = normal;
405
406 // TODO: Why is m_font not defined when we enter wxLC_LIST mode, but is
407 // defined for other modes?
408 wxFontEncoding enc;
409 if ( m_font.IsOk() )
410 enc = m_font.GetEncoding();
411 else
412 enc = wxLocale::GetSystemEncoding();
413 wxCFStringRef cfTitle( title, enc );
414 columnDesc.headerBtnDesc.titleString = cfTitle;
415
416 columnDesc.headerBtnDesc.minimumWidth = 0;
417 columnDesc.headerBtnDesc.maximumWidth = 30000;
418
419 columnDesc.propertyDesc.propertyID = property;
420 columnDesc.propertyDesc.propertyType = colType;
421 columnDesc.propertyDesc.propertyFlags = kDataBrowserListViewSortableColumn;
422 columnDesc.propertyDesc.propertyFlags |= kDataBrowserListViewTypeSelectColumn;
423 columnDesc.propertyDesc.propertyFlags |= kDataBrowserListViewNoGapForIconInHeaderButton;
424
425 if ( editable )
426 columnDesc.propertyDesc.propertyFlags |= kDataBrowserPropertyIsMutable;
427
428 verify_noerr( AddColumn( &columnDesc, pos ) );
429
430 if (width > 0)
431 {
432 wxMacDataBrowserControl::SetColumnWidth(property, width);
433 }
434
435 wxMacDataBrowserColumn *col = new wxMacDataBrowserColumn( property, colType, editable );
436
437 m_columns.Insert( col, pos );
438
439 return col;
440 }
441
442 wxListWidgetColumn* wxMacDataBrowserListControl::InsertTextColumn( unsigned pos, const wxString& title, bool editable,
443 wxAlignment just, int defaultWidth)
444 {
445 DataBrowserPropertyID property = kMinColumnId + m_nextColumnId++;
446
447 SInt16 j = teFlushLeft;
448 if ( just & wxALIGN_RIGHT )
449 j = teFlushRight;
450 else if ( just & wxALIGN_CENTER_HORIZONTAL )
451 j = teCenter;
452
453 return DoInsertColumn( pos, property, title, editable, kDataBrowserTextType, just, defaultWidth );
454 }
455
456 wxListWidgetColumn* wxMacDataBrowserListControl::InsertCheckColumn( unsigned pos , const wxString& title, bool editable,
457 wxAlignment just, int defaultWidth )
458 {
459 DataBrowserPropertyID property = kMinColumnId + m_nextColumnId++;
460
461 SInt16 j = teFlushLeft;
462 if ( just & wxALIGN_RIGHT )
463 j = teFlushRight;
464 else if ( just & wxALIGN_CENTER_HORIZONTAL )
465 j = teCenter;
466
467 return DoInsertColumn( pos, property, title, editable, kDataBrowserCheckboxType, just, defaultWidth );
468 }
469
470 wxMacDataBrowserColumn* wxMacDataBrowserListControl::GetColumnFromProperty( DataBrowserPropertyID property)
471 {
472 for ( unsigned int i = 0; i < m_columns.size() ; ++ i )
473 if ( m_columns[i]->GetProperty() == property )
474 return m_columns[i];
475
476 return NULL;
477 }
478
479 /*
480 wxMacDataItem* wxMacDataBrowserListControl::ListGetLineItem( unsigned int n )
481 {
482 return (wxMacDataItem*) GetItemFromLine(n);
483 }
484 */
485
486 unsigned int wxMacDataBrowserListControl::ListGetCount() const
487 {
488 return MacGetCount();
489 }
490
491 void wxMacDataBrowserListControl::ListDelete( unsigned int n )
492 {
493 MacDelete( n );
494 }
495
496 void wxMacDataBrowserListControl::ListInsert( unsigned int n )
497 {
498 MacInsert( n , new wxMacListBoxItem() );
499 }
500
501 void wxMacDataBrowserListControl::ListClear()
502 {
503 MacClear();
504 }
505
506 void wxMacDataBrowserListControl::ListDeselectAll()
507 {
508 wxMacDataItemBrowserSelectionSuppressor suppressor(this);
509 SetSelectedAllItems( kDataBrowserItemsRemove );
510 }
511
512 void wxMacDataBrowserListControl::ListSetSelection( unsigned int n, bool select, bool multi )
513 {
514 wxMacDataItem* item = (wxMacDataItem*) GetItemFromLine(n);
515 wxMacDataItemBrowserSelectionSuppressor suppressor(this);
516
517 if ( IsItemSelected( item ) != select )
518 {
519 if ( select )
520 SetSelectedItem( item, multi ? kDataBrowserItemsAdd : kDataBrowserItemsAssign );
521 else
522 SetSelectedItem( item, kDataBrowserItemsRemove );
523 }
524
525 ListScrollTo( n );
526 }
527
528 bool wxMacDataBrowserListControl::ListIsSelected( unsigned int n ) const
529 {
530 wxMacDataItem* item = (wxMacDataItem*) GetItemFromLine(n);
531 return IsItemSelected( item );
532 }
533
534 int wxMacDataBrowserListControl::ListGetSelection() const
535 {
536 wxMacDataItemPtr first, last;
537 GetSelectionAnchor( &first, &last );
538
539 if ( first != NULL )
540 {
541 return GetLineFromItem( first );
542 }
543
544 return -1;
545 }
546
547 int wxMacDataBrowserListControl::ListGetSelections( wxArrayInt& aSelections ) const
548 {
549 aSelections.Empty();
550 wxArrayMacDataItemPtr selectedItems;
551 GetItems( wxMacDataBrowserRootContainer, false , kDataBrowserItemIsSelected, selectedItems);
552
553 int count = selectedItems.GetCount();
554
555 for ( int i = 0; i < count; ++i)
556 {
557 aSelections.Add(GetLineFromItem(selectedItems[i]));
558 }
559
560 return count;
561 }
562
563 void wxMacDataBrowserListControl::ListScrollTo( unsigned int n )
564 {
565 UInt32 top , left ;
566 GetScrollPosition( &top , &left ) ;
567 wxMacDataItem * item = (wxMacDataItem*) GetItemFromLine( n );
568
569 // there is a bug in RevealItem that leads to situations
570 // in large lists, where the item does not get scrolled
571 // into sight, so we do a pre-scroll if necessary
572 UInt16 height ;
573 GetRowHeight( (DataBrowserItemID) item , &height ) ;
574 UInt32 linetop = n * ((UInt32) height );
575 UInt32 linebottom = linetop + height;
576 Rect rect ;
577 GetControlBounds( m_controlRef, &rect );
578
579 if ( linetop < top || linebottom > (top + rect.bottom - rect.top ) )
580 SetScrollPosition( wxMax( n-2, 0 ) * ((UInt32)height) , left ) ;
581
582 RevealItem( item , kDataBrowserRevealWithoutSelecting );
583 }
584
585 void wxMacDataBrowserListControl::UpdateLine( unsigned int n, wxListWidgetColumn* col )
586 {
587 wxMacDataBrowserColumn* dbcol = dynamic_cast<wxMacDataBrowserColumn*> (col);
588 wxMacDataItem * item = (wxMacDataItem*) GetItemFromLine( n );
589 UpdateItem(wxMacDataBrowserRootContainer, item, dbcol ? dbcol->GetProperty() : kDataBrowserNoItem );
590 }
591
592 void wxMacDataBrowserListControl::UpdateLineToEnd( unsigned int n)
593 {
594 // with databrowser inserting does not need updating the entire model, it's done by databrowser itself
595 wxMacDataItem * item = (wxMacDataItem*) GetItemFromLine( n );
596 UpdateItem(wxMacDataBrowserRootContainer, item, kDataBrowserNoItem );
597 }
598
599 // value setters
600
601 void wxMacDataBrowserCellValue::Set( CFStringRef value )
602 {
603 SetDataBrowserItemDataText( m_data, value );
604 }
605
606 void wxMacDataBrowserCellValue::Set( const wxString& value )
607 {
608 wxCFStringRef cf(value);
609 SetDataBrowserItemDataText( m_data, (CFStringRef) cf);
610 }
611
612 void wxMacDataBrowserCellValue::Set( int value )
613 {
614 SetDataBrowserItemDataValue( m_data, value );
615 }
616
617 void wxMacDataBrowserCellValue::Check( bool check )
618 {
619 SetDataBrowserItemDataButtonValue( m_data, check ? kThemeButtonOn : kThemeButtonOff);
620 }
621
622 int wxMacDataBrowserCellValue::GetIntValue() const
623 {
624 SInt32 value;
625 GetDataBrowserItemDataValue( m_data, &value );
626 return value;
627 }
628
629 wxString wxMacDataBrowserCellValue::GetStringValue() const
630 {
631 CFStringRef value;
632 GetDataBrowserItemDataText ( m_data, &value );
633 wxCFStringRef cf(value);
634 return cf.AsString();
635 }
636
637 #if 0
638
639 // in case we need that one day
640
641 // ============================================================================
642 // HIView owner-draw-based implementation
643 // ============================================================================
644
645 static pascal void ListBoxDrawProc(
646 ControlRef browser, DataBrowserItemID item, DataBrowserPropertyID property,
647 DataBrowserItemState itemState, const Rect *itemRect, SInt16 depth, Boolean isColorDevice )
648 {
649 CFStringRef cfString;
650 ThemeDrawingState themeState;
651 long systemVersion;
652
653 GetThemeDrawingState( &themeState );
654 cfString = CFStringCreateWithFormat( NULL, NULL, CFSTR("Row %d"), item );
655
656 // In this sample we handle the "selected" state; all others fall through to our "active" state
657 if ( itemState == kDataBrowserItemIsSelected )
658 {
659 ThemeBrush colorBrushID;
660
661 // TODO: switch over to wxSystemSettingsNative::GetColour() when kThemeBrushSecondaryHighlightColor
662 // is incorporated Panther DB starts using kThemeBrushSecondaryHighlightColor
663 // for inactive browser highlighting
664 if ( !IsControlActive( browser ) )
665 colorBrushID = kThemeBrushSecondaryHighlightColor;
666 else
667 colorBrushID = kThemeBrushPrimaryHighlightColor;
668
669 // First paint the hilite rect, then the text on top
670 SetThemePen( colorBrushID, 32, true );
671 PaintRect( itemRect );
672 SetThemeDrawingState( themeState, false );
673 }
674
675 DrawThemeTextBox( cfString, kThemeApplicationFont, kThemeStateActive, true, itemRect, teFlushDefault, NULL );
676 SetThemeDrawingState( themeState, true );
677
678 if ( cfString != NULL )
679 CFRelease( cfString );
680 }
681
682 #endif
683
684
685 #endif // wxUSE_LISTBOX