Exemplo n.º 1
0
wxMacDataBrowserControl::wxMacDataBrowserControl( wxWindow* peer,
                                                  const wxPoint& pos,
                                                  const wxSize& size,
                                                  long WXUNUSED(style))
                       : wxMacControl( peer )
{
    Rect bounds = wxMacGetBoundsForControl( peer, pos, size );
    OSStatus err = ::CreateDataBrowserControl(
        MAC_WXHWND(peer->MacGetTopLevelWindowRef()),
        &bounds, kDataBrowserListView, &m_controlRef );
    SetReferenceInNativeControl();
    verify_noerr( err );
    if ( gDataBrowserItemCompareUPP == NULL )
        gDataBrowserItemCompareUPP = NewDataBrowserItemCompareUPP(DataBrowserCompareProc);
    if ( gDataBrowserItemDataUPP == NULL )
        gDataBrowserItemDataUPP = NewDataBrowserItemDataUPP(DataBrowserGetSetItemDataProc);
    if ( gDataBrowserItemNotificationUPP == NULL )
    {
        gDataBrowserItemNotificationUPP =
            (DataBrowserItemNotificationUPP) NewDataBrowserItemNotificationWithItemUPP(DataBrowserItemNotificationProc);
    }

    DataBrowserCallbacks callbacks;
    InitializeDataBrowserCallbacks( &callbacks, kDataBrowserLatestCallbacks );

    callbacks.u.v1.itemDataCallback = gDataBrowserItemDataUPP;
    callbacks.u.v1.itemCompareCallback = gDataBrowserItemCompareUPP;
    callbacks.u.v1.itemNotificationCallback = gDataBrowserItemNotificationUPP;
    SetCallbacks( &callbacks );

}
Exemplo n.º 2
0
void ConfigureCheat (void)
{
	if (!cartOpen)
		return;

	OSStatus	err;
	IBNibRef	nibRef;

	err = CreateNibReference(kMacS9XCFString, &nibRef);
	if (err == noErr)
	{
		err = CreateWindowFromNib(nibRef, CFSTR("CheatEntry"), &wRef);
		if (err == noErr)
		{
			DataBrowserCallbacks	callbacks;
			EventHandlerRef			eref;
			EventHandlerUPP			eUPP;
			EventTypeSpec			events[] = { { kEventClassCommand, kEventCommandProcess      },
												 { kEventClassCommand, kEventCommandUpdateStatus },
												 { kEventClassWindow,  kEventWindowClose         } };
			HIViewRef				ctl, root;
			HIViewID				cid;

			root = HIViewGetRoot(wRef);
			cid.id = 0;
			cid.signature = kDataBrowser;
			HIViewFindByID(root, cid, &dbRef);

		#ifdef MAC_PANTHER_SUPPORT
			if (systemVersion < 0x1040)
			{
				HISize	minSize;
				Rect	rct;

				GetWindowBounds(wRef, kWindowContentRgn, &rct);
				minSize.width  = (float) (rct.right  - rct.left);
				minSize.height = (float) (rct.bottom - rct.top );
				err = SetWindowResizeLimits(wRef, &minSize, NULL);
			}
		#endif

			callbacks.version = kDataBrowserLatestCallbacks;
			err = InitDataBrowserCallbacks(&callbacks);
			callbacks.u.v1.itemDataCallback = NewDataBrowserItemDataUPP(DBClientDataCallback);
			callbacks.u.v1.itemCompareCallback = NewDataBrowserItemCompareUPP(DBCompareCallBack);
			callbacks.u.v1.itemNotificationCallback = NewDataBrowserItemNotificationUPP(DBItemNotificationCallBack);
			err = SetDataBrowserCallbacks(dbRef, &callbacks);

			if (systemVersion >= 0x1040)
				err = DataBrowserChangeAttributes(dbRef, kDataBrowserAttributeListViewAlternatingRowColors, kDataBrowserAttributeNone);

			InitCheatItems();
			ImportCheatItems();

			DataBrowserItemID	*id;

			id = new DataBrowserItemID[MAC_MAX_CHEATS];
			if (!id)
				QuitWithFatalError(0, "cheat 01");

			numofcheats = 0;

			for (unsigned int i = 0; i < MAC_MAX_CHEATS; i++)
			{
				if (citem[i].valid)
				{
					id[numofcheats] = citem[i].id;
					numofcheats++;
				}
			}

			if (numofcheats)
				err = AddDataBrowserItems(dbRef, kDataBrowserNoItem, numofcheats, id, kDataBrowserItemNoProperty);

			delete [] id;

			cid.signature = kNewButton;
			HIViewFindByID(root, cid, &ctl);
			if (numofcheats == MAC_MAX_CHEATS)
				err = DeactivateControl(ctl);
			else
				err = ActivateControl(ctl);

			cid.signature = kAllButton;
			HIViewFindByID(root, cid, &ctl);
			if (numofcheats == 0)
				err = DeactivateControl(ctl);
			else
				err = ActivateControl(ctl);

			cid.signature = kDelButton;
			HIViewFindByID(root, cid, &ctl);
			err = DeactivateControl(ctl);

			eUPP = NewEventHandlerUPP(CheatEventHandler);
			err = InstallWindowEventHandler(wRef, eUPP, GetEventTypeCount(events), events, (void *) wRef, &eref);

			err = SetKeyboardFocus(wRef, dbRef, kControlFocusNextPart);

			MoveWindowPosition(wRef, kWindowCheatEntry, true);
			ShowWindow(wRef);
			err = RunAppModalLoopForWindow(wRef);
			HideWindow(wRef);
			SaveWindowPosition(wRef, kWindowCheatEntry);

			err = RemoveEventHandler(eref);
			DisposeEventHandlerUPP(eUPP);

			DisposeDataBrowserItemNotificationUPP(callbacks.u.v1.itemNotificationCallback);
			DisposeDataBrowserItemCompareUPP(callbacks.u.v1.itemCompareCallback);
			DisposeDataBrowserItemDataUPP(callbacks.u.v1.itemDataCallback);

			CFRelease(wRef);

			DetachCheatItems();
		}

		DisposeNibReference(nibRef);
	}
}
Exemplo n.º 3
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;
}