Beispiel #1
0
wxMacDataBrowserListControl::wxMacDataBrowserListControl( wxWindow *peer, const wxPoint& pos, const wxSize& size, long style)
    : wxMacDataItemBrowserControl( peer, pos, size, style )
{
    m_nextColumnId = 0 ;

    OSStatus err = noErr;
    m_clientDataItemsType = wxClientData_None;
    if ( style & wxLB_SORT )
        m_sortOrder = SortOrder_Text_Ascending;

    DataBrowserSelectionFlags  options = kDataBrowserDragSelect;
    if ( style & wxLB_MULTIPLE )
    {
        options |= kDataBrowserAlwaysExtendSelection | kDataBrowserCmdTogglesSelection;
    }
    else if ( style & wxLB_EXTENDED )
    {
        options |= kDataBrowserCmdTogglesSelection;
    }
    else
    {
        options |= kDataBrowserSelectOnlyOne;
    }
    err = SetSelectionFlags( options );
    verify_noerr( err );

    DataBrowserListViewColumnDesc columnDesc;
    columnDesc.headerBtnDesc.titleOffset = 0;
    columnDesc.headerBtnDesc.version = kDataBrowserListViewLatestHeaderDesc;

    columnDesc.headerBtnDesc.btnFontStyle.flags =
        kControlUseFontMask | kControlUseJustMask;

    columnDesc.headerBtnDesc.btnContentInfo.contentType = kControlNoContent;
    columnDesc.headerBtnDesc.btnFontStyle.just = teFlushDefault;
    columnDesc.headerBtnDesc.btnFontStyle.font = kControlFontViewSystemFont;
    columnDesc.headerBtnDesc.btnFontStyle.style = normal;
    columnDesc.headerBtnDesc.titleString = NULL;
/*
    columnDesc.headerBtnDesc.minimumWidth = 0;
    columnDesc.headerBtnDesc.maximumWidth = 10000;

    columnDesc.propertyDesc.propertyID = kTextColumnId;
    columnDesc.propertyDesc.propertyType = kDataBrowserTextType;
    columnDesc.propertyDesc.propertyFlags = kDataBrowserTableViewSelectionColumn;
    columnDesc.propertyDesc.propertyFlags |= kDataBrowserListViewTypeSelectColumn;

    verify_noerr( AddColumn( &columnDesc, kDataBrowserListViewAppendColumn ) );
*/
    columnDesc.headerBtnDesc.minimumWidth = 0;
    columnDesc.headerBtnDesc.maximumWidth = 0;
    columnDesc.propertyDesc.propertyID = kNumericOrderColumnId;
    columnDesc.propertyDesc.propertyType = kDataBrowserPropertyRelevanceRankPart;
    columnDesc.propertyDesc.propertyFlags = kDataBrowserTableViewSelectionColumn;
    columnDesc.propertyDesc.propertyFlags |= kDataBrowserListViewTypeSelectColumn;

    verify_noerr( AddColumn( &columnDesc, kDataBrowserListViewAppendColumn ) );

/*
    SetDataBrowserSortProperty( m_controlRef , kTextColumnId);
    if ( m_sortOrder == SortOrder_Text_Ascending )
    {
        SetDataBrowserSortProperty( m_controlRef , kTextColumnId);
        SetDataBrowserSortOrder( m_controlRef , kDataBrowserOrderIncreasing);
    }
    else
*/
    {
        SetDataBrowserSortProperty( m_controlRef , kNumericOrderColumnId);
        SetDataBrowserSortOrder( m_controlRef , kDataBrowserOrderIncreasing);
    }

    verify_noerr( AutoSizeColumns() );
    verify_noerr( SetHiliteStyle(kDataBrowserTableViewFillHilite ) );
    verify_noerr( SetHeaderButtonHeight( 0 ) );
    err = SetHasScrollBars( (style & wxHSCROLL) != 0 , true );
#if 0
    // shouldn't be necessary anymore under 10.2
    GetPeer()->SetData( kControlNoPart, kControlDataBrowserIncludesFrameAndFocusTag, (Boolean)false );
    GetPeer()->SetNeedsFocusRect( true );
#endif
}
OSStatus
InitDataBrowserControl()
{
    DataBrowserCallbacks 	myCallbacks;
    ControlID 			controlID = { kNSLSample, kUserPaneControl };
    ControlRef			control;
    Rect			outRect;
    OSStatus			err;
    int				i;

    err = GetControlByID(gMainWindow, &controlID, &control);
    if (err == noErr)
    {
        GetControlBounds(control, &outRect);
        DisposeControl(control);
    }
    else
    {
        return err;
    }
    
    if (gDataBrowserControl == NULL)
    {
        err = CreateDataBrowserControl(gMainWindow, &outRect, kDataBrowserListView, &gDataBrowserControl);
        if (err == noErr)
        {
            AdvanceKeyboardFocus(gMainWindow);
            SetDataBrowserHasScrollBars(gDataBrowserControl, false, true);
            SetDataBrowserTableViewRowHeight(gDataBrowserControl, kDataBrowserRowHeight);
            SetDataBrowserSortOrder(gDataBrowserControl, kDataBrowserOrderIncreasing);
            SetDataBrowserSelectionFlags(gDataBrowserControl, kDataBrowserSelectOnlyOne);
            SetDataBrowserListViewUsePlainBackground(gDataBrowserControl, false);
    
            myCallbacks.version = kDataBrowserLatestCallbacks;
            InitDataBrowserCallbacks(&myCallbacks);
    
        #if USE_OLD_DATA_BROWSER_STRUCTS    
            myCallbacks.u.v1.clientDataCallback = NewDataBrowserItemDataUPP((DataBrowserItemDataProcPtr)MySimpleDataCallback);
            myCallbacks.u.v1.compareCallback = NewDataBrowserItemCompareUPP((DataBrowserItemCompareProcPtr)MyDataBrowserItemCompareUPP);
        #else
            myCallbacks.u.v1.itemDataCallback = NewDataBrowserItemDataUPP((DataBrowserItemDataProcPtr)MySimpleDataCallback);
            myCallbacks.u.v1.itemCompareCallback = NewDataBrowserItemCompareUPP((DataBrowserItemCompareProcPtr)MyDataBrowserItemCompareUPP);
        #endif
            
            myCallbacks.u.v1.itemNotificationCallback = NewDataBrowserItemNotificationUPP((DataBrowserItemNotificationProcPtr)MySimpleNotificationCallback);

            err = SetDataBrowserCallbacks(gDataBrowserControl, &myCallbacks);
            if (err != noErr) return err;
        }
        else
        {
            return err;
        }
    }
    
    err = AddNameColumnToList();
    if (err == noErr)
    {        
        SetDataBrowserListViewDisclosureColumn(gDataBrowserControl, kNameColumn, false);
        SetDataBrowserSortProperty(gDataBrowserControl, kNameColumn);        
        
        for (i = 0; i < kMaxNeighborhoods; i++)
        {
            gNeighborhoodInfo.neighborhoodSize[i] = 0;
            gNeighborhoodInfo.isNeighborhoodOpen[i] = false;
            gNeighborhoodInfo.isDefaultNeighborhood[i] = false;
            gNeighborhoodInfo.isNeighborhoodVisible[i] = false;
            gLookupInfo[i + 1].sLookupActive = false;
            gLookupInfo[i + 1].nLookupActive = false;
        }
        
        gNeighborhoodInfo.neighborhoodCount = 0;
        gSelectedItem = 0;
        
        DoNeighborhoodLookup(kDefaultNeighborhoods);
    }
    
    return err;
}
Beispiel #3
0
OSStatus wxMacDataBrowserControl::SetSortOrder( DataBrowserSortOrder order )
{
    return SetDataBrowserSortOrder( m_controlRef , order );
}