X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/524c47aa3adf2af11a3069fd5da035a604f08f66..bb996f289574defb0ae4339ae8e46ff3cf6fa54c:/src/osx/carbon/utils.cpp diff --git a/src/osx/carbon/utils.cpp b/src/osx/carbon/utils.cpp index 7030447039..2d2b5ccdf9 100644 --- a/src/osx/carbon/utils.cpp +++ b/src/osx/carbon/utils.cpp @@ -45,13 +45,7 @@ #include "wx/evtloop.h" -#if defined(__MWERKS__) && wxUSE_UNICODE -#if __MWERKS__ < 0x4100 - #include -#endif -#endif - -#if wxUSE_BASE +#if wxUSE_GUI // Emit a beeeeeep void wxBell() @@ -62,17 +56,13 @@ void wxBell() else #endif #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 - SysBeep(30); + AlertSoundPlay(); #else { } #endif } -#endif // wxUSE_BASE - -#if wxUSE_GUI - wxTimerImpl* wxGUIAppTraits::CreateTimerImpl(wxTimer *timer) { return new wxOSXTimerImpl(timer); @@ -144,8 +134,17 @@ wxString wxMacFindFolder( short vol, #endif // wxUSE_BASE + +// ============================================================================ +// GUI-only functions from now on +// ============================================================================ + #if wxUSE_GUI +// ---------------------------------------------------------------------------- +// Miscellaneous functions +// ---------------------------------------------------------------------------- + void wxGetMousePosition( int* x, int* y ) { Point pt; @@ -186,45 +185,6 @@ void wxClientDisplayRect(int *x, int *y, int *width, int *height) #endif // wxUSE_GUI -#if wxUSE_BASE -// ---------------------------------------------------------------------------- -// Common Event Support -// ---------------------------------------------------------------------------- - -void wxMacWakeUp() -{ - OSStatus err = noErr; - -#if wxOSX_USE_CARBON -#if 0 - // lead sometimes to race conditions, although all calls used should be thread safe ... - static wxMacCarbonEvent s_wakeupEvent; - if ( !s_wakeupEvent.IsValid() ) - { - err = s_wakeupEvent.Create( 'WXMC', 'WXMC', GetCurrentEventTime(), - kEventAttributeNone ); - } - if ( err == noErr ) - { - - if ( IsEventInQueue( GetMainEventQueue() , s_wakeupEvent ) ) - return; - s_wakeupEvent.SetCurrentTime(); - err = PostEventToQueue(GetMainEventQueue(), s_wakeupEvent, - kEventPriorityHigh ); - } -#else - wxMacCarbonEvent wakeupEvent; - wakeupEvent.Create( 'WXMC', 'WXMC', GetCurrentEventTime(), - kEventAttributeNone ); - err = PostEventToQueue(GetMainEventQueue(), wakeupEvent, - kEventPriorityHigh ); -#endif -#endif -} - -#endif // wxUSE_BASE - #if wxUSE_GUI // ---------------------------------------------------------------------------- @@ -393,7 +353,8 @@ OSStatus wxMacDataBrowserControl::AddColumn( DataBrowserListViewColumnDesc *colu return AddDataBrowserListViewColumn( m_controlRef, columnDesc, position ); } -OSStatus wxMacDataBrowserControl::GetColumnIDFromIndex( DataBrowserTableViewColumnIndex position, DataBrowserTableViewColumnID* id ){ +OSStatus wxMacDataBrowserControl::GetColumnIDFromIndex( DataBrowserTableViewColumnIndex position, DataBrowserTableViewColumnID* id ) +{ return GetDataBrowserTableViewColumnProperty( m_controlRef, position, id ); } @@ -614,6 +575,11 @@ OSStatus wxMacDataBrowserControl::SetDisclosureColumn( DataBrowserPropertyID pro return SetDataBrowserListViewDisclosureColumn( m_controlRef, property, expandableRows); } +OSStatus wxMacDataBrowserControl::GetItemPartBounds( DataBrowserItemID item, DataBrowserPropertyID property, DataBrowserPropertyPart part, Rect * bounds ) +{ + return GetDataBrowserItemPartBounds( m_controlRef, item, property, part, bounds); +} + // ============================================================================ // Higher-level Databrowser // ============================================================================ @@ -679,11 +645,10 @@ bool wxMacDataItem::IsLessThan(wxMacDataItemBrowserControl *WXUNUSED(owner) , const wxMacDataItem* rhs, DataBrowserPropertyID sortProperty) const { - const wxMacDataItem* otherItem = wx_const_cast(wxMacDataItem*,rhs); bool retval = false; if ( sortProperty == kNumericOrderColumnId ) - retval = m_order < otherItem->m_order; + retval = m_order < rhs->m_order; return retval; } @@ -747,13 +712,7 @@ Boolean wxMacDataItemBrowserControl::CompareItems(DataBrowserItemID itemOneID, { wxMacDataItem* itemOne = (wxMacDataItem*) itemOneID; wxMacDataItem* itemTwo = (wxMacDataItem*) itemTwoID; - return CompareItems( itemOne , itemTwo , sortProperty ); -} -Boolean wxMacDataItemBrowserControl::CompareItems(const wxMacDataItem* itemOne, - const wxMacDataItem* itemTwo, - DataBrowserPropertyID sortProperty) -{ Boolean retval = false; if ( itemOne != NULL ) retval = itemOne->IsLessThan( this , itemTwo , sortProperty); @@ -767,15 +726,6 @@ OSStatus wxMacDataItemBrowserControl::GetSetItemData( Boolean changeValue ) { wxMacDataItem* item = (wxMacDataItem*) itemID; - return GetSetItemData(item, property, itemData , changeValue ); -} - -OSStatus wxMacDataItemBrowserControl::GetSetItemData( - wxMacDataItem* item, - DataBrowserPropertyID property, - DataBrowserItemDataRef itemData, - Boolean changeValue ) -{ OSStatus err = errDataBrowserPropertyNotSupported; switch( property ) { @@ -801,14 +751,6 @@ void wxMacDataItemBrowserControl::ItemNotification( DataBrowserItemDataRef itemData) { wxMacDataItem* item = (wxMacDataItem*) itemID; - ItemNotification( item , message, itemData); -} - -void wxMacDataItemBrowserControl::ItemNotification( - const wxMacDataItem* item, - DataBrowserItemNotification message, - DataBrowserItemDataRef itemData) -{ if (item != NULL) item->Notification( this, message, itemData); } @@ -883,7 +825,9 @@ void wxMacDataItemBrowserControl::UpdateItems(const wxMacDataItem *container, delete [] items; } -void wxMacDataItemBrowserControl::InsertColumn(int colId, DataBrowserPropertyType colType, +static int column_id_counter = 0; + +void wxMacDataItemBrowserControl::InsertColumn(int col, DataBrowserPropertyType colType, const wxString& title, SInt16 just, int defaultWidth) { DataBrowserListViewColumnDesc columnDesc; @@ -901,7 +845,7 @@ void wxMacDataItemBrowserControl::InsertColumn(int colId, DataBrowserPropertyTyp // TODO: Why is m_font not defined when we enter wxLC_LIST mode, but is // defined for other modes? wxFontEncoding enc; - if ( m_font.Ok() ) + if ( m_font.IsOk() ) enc = m_font.GetEncoding(); else enc = wxLocale::GetSystemEncoding(); @@ -911,18 +855,20 @@ void wxMacDataItemBrowserControl::InsertColumn(int colId, DataBrowserPropertyTyp columnDesc.headerBtnDesc.minimumWidth = 0; columnDesc.headerBtnDesc.maximumWidth = 30000; - columnDesc.propertyDesc.propertyID = (kMinColumnId + colId); + DataBrowserPropertyID id = kMinColumnId + column_id_counter; + column_id_counter++; + + columnDesc.propertyDesc.propertyID = id; columnDesc.propertyDesc.propertyType = colType; columnDesc.propertyDesc.propertyFlags = kDataBrowserListViewSortableColumn; columnDesc.propertyDesc.propertyFlags |= kDataBrowserListViewTypeSelectColumn; columnDesc.propertyDesc.propertyFlags |= kDataBrowserListViewNoGapForIconInHeaderButton; - verify_noerr( AddColumn( &columnDesc, kDataBrowserListViewAppendColumn ) ); + verify_noerr( AddColumn( &columnDesc, col ) ); if (defaultWidth > 0){ - SetColumnWidth(colId, defaultWidth); + SetColumnWidth(col, defaultWidth); } - } void wxMacDataItemBrowserControl::SetColumnWidth(int colId, int width) @@ -981,6 +927,7 @@ void wxMacDataItemBrowserControl::RemoveItems(wxMacDataItem *container, wxArrayM void wxMacDataItemBrowserControl::RemoveAllItems(wxMacDataItem *container) { + SetScrollPosition(0, 0); OSStatus err = wxMacDataBrowserControl::RemoveItems( (DataBrowserItemID)container, 0 , NULL , kDataBrowserItemNoProperty ); verify_noerr( err ); } @@ -1038,10 +985,9 @@ void wxMacDataItemBrowserControl::MacDelete( unsigned int n ) void wxMacDataItemBrowserControl::MacInsert( unsigned int n, wxMacDataItem* item) { - SInt32 frontLineOrder = 0; - if ( m_sortOrder == SortOrder_None ) { + // increase the order of the lines to be shifted unsigned int lines = MacGetCount(); for ( unsigned int i = n; i < lines; ++i) @@ -1049,22 +995,21 @@ void wxMacDataItemBrowserControl::MacInsert( unsigned int n, wxMacDataItem* item wxMacDataItem* iter = (wxMacDataItem*) GetItemFromLine(i); iter->SetOrder( iter->GetOrder() + 1 ); } + +#if 0 + // I don't understand what this code is supposed to do, RR. + SInt32 frontLineOrder = 0; if ( n > 0 ) { wxMacDataItem* iter = (wxMacDataItem*) GetItemFromLine(n-1); - frontLineOrder = iter->GetOrder(); + frontLineOrder = iter->GetOrder()+1; } +#else + item->SetOrder( n ); +#endif } - wxArrayMacDataItemPtr ids; - ids.SetCount( 1 ); - - if ( m_sortOrder == SortOrder_None ) - item->SetOrder( frontLineOrder + 1 ); - - ids[0] = item; - - AddItems( wxMacDataBrowserRootContainer, ids ); + AddItem( wxMacDataBrowserRootContainer, item ); } void wxMacDataItemBrowserControl::MacClear()