Пример #1
0
// --------------------------------------------------------------------------------------
ControlRef CreateIconDataBrowser(WindowRef window, const Rect *dbRect, ControlRef *userPanes)
{
    ControlRef dataBrowserControl;
    DataBrowserListViewColumnDesc columnDesc;
    DataBrowserItemID firstItem;

    CreateDataBrowserControl(window, dbRect, kDataBrowserListView, &dataBrowserControl);

    SetDataBrowserHasScrollBars(dataBrowserControl, false, true);
    SetDataBrowserSelectionFlags(dataBrowserControl, kDataBrowserDragSelect |
                                 kDataBrowserSelectOnlyOne);
    SetDataBrowserListViewHeaderBtnHeight(dataBrowserControl, 0);	// no header button
    SetDataBrowserTableViewHiliteStyle(dataBrowserControl, kDataBrowserTableViewFillHilite);
    // because kDataBrowserTableViewMinimalHilite would require us to provide a hit test
    // callback which we would just return true from anyways

    columnDesc.propertyDesc.propertyID = kCategoryProperty;
    columnDesc.propertyDesc.propertyType = kDataBrowserCustomType;	// because
    // kDataBrowserIconAndTextType doesn't draw the way we want
    columnDesc.propertyDesc.propertyFlags = kDataBrowserDefaultPropertyFlags |
                                            kDataBrowserListViewSelectionColumn;
    columnDesc.headerBtnDesc.version = kDataBrowserListViewLatestHeaderDesc;
    columnDesc.headerBtnDesc.minimumWidth = kColumnWidth;
    columnDesc.headerBtnDesc.maximumWidth = kColumnWidth;
    columnDesc.headerBtnDesc.titleOffset = 0;
    columnDesc.headerBtnDesc.titleString = NULL;
    columnDesc.headerBtnDesc.initialOrder = kDataBrowserOrderIncreasing;
    columnDesc.headerBtnDesc.btnFontStyle.flags = 0;
    columnDesc.headerBtnDesc.btnContentInfo.contentType = kControlNoContent;
    AddDataBrowserListViewColumn(dataBrowserControl, &columnDesc,
                                 kDataBrowserListViewAppendColumn);

    /* We need to wait to set the row height until here because
       AddDataBrowserListViewColumn will resize the row height. */
#if TARGET_API_MAC_OSX
    SetDataBrowserTableViewRowHeight(dataBrowserControl, kRowHeight);
#else		// Mac OS 8/9 under CarbonLib adds 1 to the row height you provide
    SetDataBrowserTableViewRowHeight(dataBrowserControl, kRowHeight - 1);
#endif

    SetDataBrowserListViewUsePlainBackground(dataBrowserControl, true);

    if (gCallbackRefCount == 0)
    {
        gIconDBCallbacks.u.v1.itemNotificationCallback = NewDataBrowserItemNotificationUPP(IconDataBrowserItemSelectionCB);
        gIconDBCustomCallbacks.u.v1.drawItemCallback = NewDataBrowserDrawItemUPP(DrawIconDataBrowserItemCB);
    }
    SetDataBrowserCallbacks(dataBrowserControl, &gIconDBCallbacks);
    SetDataBrowserCustomCallbacks(dataBrowserControl, &gIconDBCustomCallbacks);
    gCallbackRefCount++;

    firstItem = addItemsToIconDB(dataBrowserControl, userPanes);
    SetDataBrowserSelectedItems(dataBrowserControl, 1, &firstItem, kDataBrowserItemsAssign);
    SetKeyboardFocus(window, dataBrowserControl, kControlFocusNextPart);

    return dataBrowserControl;
}
Пример #2
0
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;
}
Пример #3
0
OSStatus wxMacDataBrowserControl::SetDefaultRowHeight( UInt16 height )
{
    return SetDataBrowserTableViewRowHeight( m_controlRef , height );
}