void dialog_pose_move_settings_load(void) { int mesh_idx; model_pose_move_type *pose_move; pose_move=&model.animates[dialog_animate_idx].pose_moves[dialog_pose_move_idx]; // set controls dialog_set_combo(dialog_animation_settings_wind,kAnimationPosePose,0,pose_move->pose_idx); dialog_set_int(dialog_animation_settings_wind,kAnimationPoseTime,0,pose_move->msec); dialog_set_value(dialog_animation_settings_wind,kAnimationPoseAccel,0,(int)(pose_move->acceleration*100.0f)); dialog_set_float(dialog_animation_settings_wind,kAnimationPoseSwayX,0,pose_move->sway.x); dialog_set_float(dialog_animation_settings_wind,kAnimationPoseSwayY,0,pose_move->sway.y); dialog_set_float(dialog_animation_settings_wind,kAnimationPoseSwayZ,0,pose_move->sway.z); dialog_set_float(dialog_animation_settings_wind,kAnimationPoseMoveX,0,pose_move->mov.x); dialog_set_float(dialog_animation_settings_wind,kAnimationPoseMoveY,0,pose_move->mov.y); dialog_set_float(dialog_animation_settings_wind,kAnimationPoseMoveZ,0,pose_move->mov.z); dialog_set_bone_combo(dialog_animation_settings_wind,kAnimationSoundBone,0,pose_move->sound.bone_idx); dialog_special_combo_fill_sound(dialog_animation_settings_wind,kAnimationSoundName,0,pose_move->sound.name); dialog_set_float(dialog_animation_settings_wind,kAnimationSoundPitch,0,pose_move->sound.pitch); dialog_set_boolean(dialog_animation_settings_wind,kAnimationSoundGlobal,0,pose_move->sound.no_position); dialog_particle_idx=-1; RemoveDataBrowserItems(dialog_particle_list,kDataBrowserNoItem,0,NULL,kDataBrowserItemNoProperty); AddDataBrowserItems(dialog_particle_list,kDataBrowserNoItem,pose_move->particle.count,NULL,kDataBrowserItemNoProperty); dialog_ring_idx=-1; RemoveDataBrowserItems(dialog_ring_list,kDataBrowserNoItem,0,NULL,kDataBrowserItemNoProperty); AddDataBrowserItems(dialog_ring_list,kDataBrowserNoItem,pose_move->ring.count,NULL,kDataBrowserItemNoProperty); dialog_set_bone_combo(dialog_animation_settings_wind,kAnimationFlashBone,0,pose_move->flash.bone_idx); dialog_set_int(dialog_animation_settings_wind,kAnimationFlashIntensity,0,pose_move->flash.intensity); dialog_set_int(dialog_animation_settings_wind,kAnimationFlashLiveTime,0,pose_move->flash.flash_msec); dialog_set_int(dialog_animation_settings_wind,kAnimationFlashFadeTime,0,pose_move->flash.fade_msec); dialog_set_color(dialog_animation_settings_wind,kAnimationFlashColor,0,&pose_move->flash.col); dialog_set_int(dialog_animation_settings_wind,kAnimationShakeDistance,0,pose_move->shake.distance); dialog_set_int(dialog_animation_settings_wind,kAnimationShakeSize,0,pose_move->shake.size); dialog_set_int(dialog_animation_settings_wind,kAnimationShakeLiveTime,0,pose_move->shake.life_msec); mesh_idx=model_find_mesh(&model,pose_move->mesh_fade.name); if (mesh_idx==-1) { dialog_set_combo(dialog_animation_settings_wind,kAnimationMeshName,0,0); } else { dialog_set_combo(dialog_animation_settings_wind,kAnimationMeshName,0,(mesh_idx+2)); } dialog_set_int(dialog_animation_settings_wind,kAnimationMeshFadeInTime,0,pose_move->mesh_fade.fade_in_msec); dialog_set_int(dialog_animation_settings_wind,kAnimationMeshFadeLifeTime,0,pose_move->mesh_fade.fade_life_msec); dialog_set_int(dialog_animation_settings_wind,kAnimationMeshFadeOutTime,0,pose_move->mesh_fade.fade_out_msec); DrawControls(dialog_animation_settings_wind); }
// --------------------------------------------------------------------------- // // ----------- void bToolGeomWithJoin::populate_types(WindowRef wd){ ControlRef c; ControlID cid={kToolGeomWithJoinSign,kToolGeomWithJoinTypesID}; GetControlByID(wd,&cid,&c); for(DataBrowserItemID itemId=1;itemId<=_gapp->typesMgr()->count();itemId++){ AddDataBrowserItems(c,kDataBrowserNoItem,1,&itemId,kToolGeomWithJoinTypesCheckProperty); AddDataBrowserItems(c,kDataBrowserNoItem,1,&itemId,kToolGeomWithJoinTypesNameProperty); } }
OSStatus wxMacDataBrowserControl::AddItems( DataBrowserItemID container, UInt32 numItems, const DataBrowserItemID *items, DataBrowserPropertyID preSortProperty ) { return AddDataBrowserItems( m_controlRef, container, numItems, items, preSortProperty ); }
void dialog_ring_list_reset(void) { dialog_ring_idx=-1; RemoveDataBrowserItems(dialog_ring_list,kDataBrowserNoItem,0,NULL,kDataBrowserItemNoProperty); AddDataBrowserItems(dialog_ring_list,kDataBrowserNoItem,model.animates[dialog_animate_idx].pose_moves[dialog_pose_move_idx].ring.count,NULL,kDataBrowserItemNoProperty); Draw1Control(dialog_ring_list); }
void dialog_pose_list_reset(void) { DataBrowserItemID itemID; RemoveDataBrowserItems(dialog_pose_move_list,kDataBrowserNoItem,0,NULL,kDataBrowserItemNoProperty); AddDataBrowserItems(dialog_pose_move_list,kDataBrowserNoItem,model.animates[dialog_animate_idx].npose_move,NULL,kDataBrowserItemNoProperty); itemID=dialog_pose_move_idx+1; SetDataBrowserSelectedItems(dialog_pose_move_list,1,&itemID,kDataBrowserItemsAssign); Draw1Control(dialog_pose_move_list); }
static void AddCheatItem (void) { OSStatus err; HIViewRef ctl, root; HIViewID cid; DataBrowserItemID id[1]; unsigned int i; if (numofcheats == MAC_MAX_CHEATS) return; for (i = 0; i < MAC_MAX_CHEATS; i++) if (citem[i].valid == false) break; if (i == MAC_MAX_CHEATS) return; numofcheats++; citem[i].valid = true; citem[i].enabled = false; citem[i].address = 0; citem[i].value = 0; sprintf(citem[i].description, "Cheat %03" PRIu32, citem[i].id); id[0] = citem[i].id; err = AddDataBrowserItems(dbRef, kDataBrowserNoItem, 1, id, kDataBrowserItemNoProperty); err = RevealDataBrowserItem(dbRef, id[0], kCmAddress, true); root = HIViewGetRoot(wRef); cid.id = 0; if (numofcheats == MAC_MAX_CHEATS) { cid.signature = kNewButton; HIViewFindByID(root, cid, &ctl); err = DeactivateControl(ctl); } if (numofcheats) { cid.signature = kAllButton; HIViewFindByID(root, cid, &ctl); err = ActivateControl(ctl); } }
// Add item OSStatus OPL_DSNList::addItem(CFStringRef dsn, int item_type) { OSStatus err; m_nextItemID++; CFNumberRef num = CFNumberCreate(NULL, kCFNumberSInt32Type, &m_nextItemID); CFDictionarySetValue(m_items, num, dsn); CFDictionarySetValue(m_itemsType, num, CFNumberCreate(NULL, kCFNumberSInt32Type, &item_type)); // add new test item DataBrowserItemID itemID = m_nextItemID; err = AddDataBrowserItems(m_itemView, kDataBrowserNoItem, 1, &itemID, kDataBrowserItemNoProperty); require_noerr(err, error); // update control DrawOneControl(m_itemView); error: return err; }
void AddNeighborhoodToList(char * neighborhood, UInt32 parentID) { CFStringRef tempNeighborhood = NULL; CFComparisonResult result = -1; UInt32 neighborhoodID, i; if (neighborhood) { tempNeighborhood = CFStringCreateWithCString(NULL, neighborhood, CFStringGetSystemEncoding()); if (tempNeighborhood) { // Check if the item is already in our list. If it is, "result" will be kCFCompareEqualTo. for (i = 0; i < kMaxNeighborhoods; i++) { if (gData[i] && gNeighborhoodInfo.parentID[i] == parentID) { result = CFStringCompare(tempNeighborhood, gData[i], kCFCompareCaseInsensitive); if (result == kCFCompareEqualTo) break; } } if (result != kCFCompareEqualTo) { // Only add the item if the parent neighborhood is open and visible in the Data Browser. if ((gNeighborhoodInfo.isNeighborhoodOpen[parentID - 1] && gNeighborhoodInfo.isNeighborhoodVisible[parentID - 1]) || parentID == 0) { neighborhoodID = IncrementAtomic(&gNeighborhoodInfo.neighborhoodCount); if (++neighborhoodID < kMaxNeighborhoods) { gNeighborhoodInfo.parentID[neighborhoodID - 1] = parentID; gData[neighborhoodID - 1] = CFStringCreateCopy(NULL, tempNeighborhood); AddDataBrowserItems(gDataBrowserControl, parentID, 1, &neighborhoodID, kNameColumn); if (parentID == kDataBrowserNoItem) { gNeighborhoodInfo.isDefaultNeighborhood[neighborhoodID - 1] = true; } else { gNeighborhoodInfo.isDefaultNeighborhood[neighborhoodID - 1] = false; } } else { DecrementAtomic(&gNeighborhoodInfo.neighborhoodCount); } } } else if (result == kCFCompareEqualTo) { if (gNeighborhoodInfo.isNeighborhoodOpen[parentID - 1] && gNeighborhoodInfo.isNeighborhoodVisible[parentID - 1]) { neighborhoodID = i + 1; if (gNeighborhoodInfo.isNeighborhoodVisible[i] == false) { AddDataBrowserItems(gDataBrowserControl, parentID, 1, &neighborhoodID, kNameColumn); if (gNeighborhoodInfo.isNeighborhoodOpen[i]) { OpenDataBrowserContainer(gDataBrowserControl, neighborhoodID); } } else { if (gNeighborhoodInfo.isNeighborhoodOpen[i]) { CancelServicesLookup(parentID); CancelNeighborhoodLookup(parentID); InstallEventLoopTimer(GetMainEventLoop(), 0.3, 0, gMyStartLookupTimerUPP, (void *)(neighborhoodID), NULL); } } } } CFRelease(tempNeighborhood); } free(neighborhood); } }
// -------------------------------------------------------------------------------------- static DataBrowserItemID addItemsToIconDB(ControlRef iconDataBrowser, ControlRef *userPanes) { IconDBItemDataRec *itemsData, *rowItemData; CFBundleRef mainBundle; CFIndex rowNumber; DataBrowserItemID items[kNumberOfRows]; CFStringRef catNameKeys[kNumberOfRows]; itemsData = CFAllocatorAllocate(kCFAllocatorDefault, kNumberOfRows * sizeof(IconDBItemDataRec), 0); mainBundle = CFBundleGetMainBundle(); if (!gIconsRegistered) // if we didn't register our icons already, we need to { CFArrayRef iconURLs; FSRef iconFile; FSSpec iconSpec; iconURLs = CFBundleCopyResourceURLsOfType(mainBundle, CFSTR("icns"), CFSTR("PrefCategories")); for (rowNumber = 0; rowNumber < kNumberOfRows; rowNumber++) { CFURLGetFSRef(CFArrayGetValueAtIndex(iconURLs, rowNumber), &iconFile); #if TARGET_API_MAC_OSX #pragma unused (iconSpec) RegisterIconRefFromFSRef(kAppSignature, 'Cat0' + rowNumber, &iconFile, &((itemsData + rowNumber)->icon)); #else FSGetCatalogInfo(&iconFile, kFSCatInfoNone, NULL, NULL, &iconSpec, NULL); RegisterIconRefFromIconFile(kAppSignature, 'Cat0' + rowNumber, &iconSpec, &((itemsData + rowNumber)->icon)); #endif } CFRelease(iconURLs); gIconsRegistered = true; } else // the icons are already registered so we just have to get them { for (rowNumber = 0; rowNumber < kNumberOfRows; rowNumber++) { GetIconRef(kOnSystemDisk, kAppSignature, 'Cat0' + rowNumber, &((itemsData + rowNumber)->icon)); } } catNameKeys[0] = CFSTR("Panel 1"); // this is necessary because you have to use catNameKeys[1] = CFSTR("Panel 2"); // constant strings with CFSTR catNameKeys[2] = CFSTR("Panel 3"); // if we didn't do this then we couldn't get catNameKeys[3] = CFSTR("Panel 4"); // the strings in a loop catNameKeys[4] = CFSTR("Panel 5"); catNameKeys[5] = CFSTR("Panel 6"); catNameKeys[6] = CFSTR("Panel 7"); catNameKeys[7] = CFSTR("Panel 8"); catNameKeys[8] = CFSTR("Panel 9"); catNameKeys[9] = CFSTR("Panel 10"); for (rowNumber = 0; rowNumber < kNumberOfRows; rowNumber++) // now get the names { // and set the user panes rowItemData = itemsData + rowNumber; items[rowNumber] = (DataBrowserItemID)rowItemData; /* We use CFCopyLocalilzedStringFromTableInBundle here instead of CFCopyLocalizedString to avoid a call to CFBundleGetMainBundle every trip around the loop. */ rowItemData->name = CFCopyLocalizedStringFromTableInBundle(catNameKeys[rowNumber], NULL, mainBundle, NULL); rowItemData->userPane = *(userPanes + rowNumber); } AddDataBrowserItems(iconDataBrowser, kDataBrowserNoItem, kNumberOfRows, items, kDataBrowserItemNoProperty); return *items; }
pascal OSStatus gensetup_add_clicked (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) { TGENSETUP *gensetup_t = (TGENSETUP *) inUserData; DataBrowserItemID item = DBITEM_ID + 1; DataBrowserCallbacks dbCallbacks; ThemeDrawingState outState = NULL; UInt16 colSize[2] = { 150, 250 }; SInt16 outBaseline; Point ioBound; CFStringRef data[2]; Size len; int i = 0, j; if (gensetup_t) { GetThemeDrawingState (&outState); GetControlData (gensetup_t->key_entry, 0, kControlEditTextCFStringTag, sizeof (CFStringRef), &data[0], &len); if (CFStringGetLength(data[0])) { GetControlData (gensetup_t->value_entry, 0, kControlEditTextCFStringTag, sizeof (CFStringRef), &data[1], &len); /* Try to see if the keyword already exists */ for (i = 0; i < DSNSETUP_nrows; i++, item++) if (CFStringCompare (data[0], DSNSETUP_array[0][i], 0) == kCFCompareEqualTo) goto done; /* Install an event handler on the component databrowser */ dbCallbacks.version = kDataBrowserLatestCallbacks; InitDataBrowserCallbacks (&dbCallbacks); dbCallbacks.u.v1.itemNotificationCallback = NewDataBrowserItemNotificationUPP (dsnsetup_notification_item); /* On Mac OS X 10.0.x : this is clientDataCallback */ dbCallbacks.u.v1.itemDataCallback = NewDataBrowserItemDataUPP (dsnsetup_getset_item); SetDataBrowserCallbacks (gensetup_t->key_list, &dbCallbacks); /* Begin the draw of the data browser */ SetDataBrowserTarget (gensetup_t->key_list, DBITEM_ID); /* An update operation */ if(i<DSNSETUP_nrows) { CFRelease (DSNSETUP_array[1][i]); DSNSETUP_array[1][i] = data[1]; UpdateDataBrowserItems (gensetup_t->key_list, DBITEM_ID, 1, &item, GSKEYWORD_ID, kDataBrowserItemNoProperty); } else if(len) { DSNSETUP_array[0][i] = data[0]; DSNSETUP_array[1][i] = data[1]; AddDataBrowserItems (gensetup_t->key_list, DBITEM_ID, 1, &item, GSKEYWORD_ID); DSNSETUP_nrows++; } for(j = 0 ; j < DSNSETUP_nrows ; j++) { for(i = 0 ; i < 2 ; i++) { GetThemeTextDimensions (DSNSETUP_array[i][j], kThemeSystemFont, kThemeStateActive, false, &ioBound, &outBaseline); if(colSize[i] < ioBound.h) colSize[i] = ioBound.h; } } ActivateControl (gensetup_t->key_list); /* Resize the columns to have a good look */ SetDataBrowserTableViewNamedColumnWidth (gensetup_t->key_list, GSKEYWORD_ID, colSize[0] + 20); SetDataBrowserTableViewNamedColumnWidth (gensetup_t->key_list, GSVALUE_ID, colSize[1] + 20); DrawOneControl (gensetup_t->key_list); /* Remove the DataBrowser callback */ SetDataBrowserCallbacks (NULL, &dbCallbacks); } done: SetControlData (gensetup_t->key_entry, 0, kControlEditTextTextTag, 0, ""); DrawOneControl (gensetup_t->key_entry); SetControlData (gensetup_t->value_entry, 0, kControlEditTextTextTag, 0, ""); DrawOneControl (gensetup_t->value_entry); DeactivateControl (DSNSETUP->bupdate); DrawOneControl (DSNSETUP->bupdate); } return noErr; }
static void addkeywords_to_list (ControlRef widget, LPCSTR attrs, TGENSETUP * gensetup_t) { DataBrowserItemID item = DBITEM_ID + 1; DataBrowserCallbacks dbCallbacks; ThemeDrawingState outState = NULL; UInt16 colSize[2] = { 150, 250 }; SInt16 outBaseline; Point ioBound; char *curr, *cour; int i; if (!widget) return; GetThemeDrawingState (&outState); /* Install an event handler on the component databrowser */ dbCallbacks.version = kDataBrowserLatestCallbacks; InitDataBrowserCallbacks (&dbCallbacks); dbCallbacks.u.v1.itemNotificationCallback = NewDataBrowserItemNotificationUPP (dsnsetup_notification_item); /* On Mac OS X 10.0.x : this is clientDataCallback */ dbCallbacks.u.v1.itemDataCallback = NewDataBrowserItemDataUPP (dsnsetup_getset_item); SetDataBrowserCallbacks (widget, &dbCallbacks); /* Begin the draw of the data browser */ SetDataBrowserTarget (widget, DBITEM_ID); /* Make the clean up */ for (i = 0; i < DSNSETUP_nrows; i++) { CFRelease (DSNSETUP_array[0][i]); DSNSETUP_array[0][i] = NULL; CFRelease (DSNSETUP_array[1][i]); DSNSETUP_array[1][i] = NULL; } /* Global Initialization */ DSNSETUP_nrows = 0; item = DBITEM_ID + 1; for (curr = (LPSTR) attrs; *curr; curr += (STRLEN (curr) + 1)) { if (!strncasecmp (curr, "DSN=", STRLEN ("DSN=")) || !strncasecmp (curr, "Driver=", STRLEN ("Driver=")) || !strncasecmp (curr, "Description=", STRLEN ("Description="))) continue; if ((cour = strchr ((char*)curr, '='))) { *cour = '\0'; DSNSETUP_array[0][DSNSETUP_nrows] = CFStringCreateWithCString (NULL, curr, kCFStringEncodingUTF8); *cour = '='; DSNSETUP_array[1][DSNSETUP_nrows] = CFStringCreateWithCString (NULL, ((char*)cour) + 1, kCFStringEncodingUTF8); } else DSNSETUP_array[0][DSNSETUP_nrows] = CFStringCreateWithCString (NULL, "", kCFStringEncodingUTF8); for(i = 0 ; i < 2 ; i++) { GetThemeTextDimensions (DSNSETUP_array[i][DSNSETUP_nrows], kThemeSystemFont, kThemeStateActive, false, &ioBound, &outBaseline); if(colSize[i] < ioBound.h) colSize[i] = ioBound.h; } AddDataBrowserItems (widget, DBITEM_ID, 1, &item, GSKEYWORD_ID); item++; DSNSETUP_nrows++; } ActivateControl (widget); /* Resize the columns to have a good look */ SetDataBrowserTableViewNamedColumnWidth (widget, GSKEYWORD_ID, colSize[0] + 20); SetDataBrowserTableViewNamedColumnWidth (widget, GSVALUE_ID, colSize[1] + 20); DrawOneControl (widget); /* Remove the DataBrowser callback */ SetDataBrowserCallbacks (NULL, &dbCallbacks); }
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); } }
static void DoRefresh(void) // Called in response to a click of the "Refresh" button. // Also called to refresh the list after other actions have // changed it. Also called at application startup to // establish an initial value for the list. { OSStatus err; CFArrayRef items; CFIndex itemCount; CFIndex itemIndex; DataBrowserItemID * itemsIDArray; itemsIDArray = NULL; items = NULL; // Get the array from LoginItemsAE. err = LIAECopyLoginItems(&items); if (err == noErr) { // Swap it into gItems. CFQRelease(gItems); gItems = items; items = NULL; // to prevent the release at the end of this function // Remove any existing items. if (err == noErr) { err = RemoveDataBrowserItems( gDataControl, kDataBrowserNoItem, // from root 0, // all items NULL, // " " kDataBrowserItemNoProperty ); } // Add the new items. if (err == noErr) { itemCount = CFArrayGetCount(gItems); itemsIDArray = calloc(itemCount, sizeof(DataBrowserItemID)); if (itemsIDArray == NULL) { err = memFullErr; } } if (err == noErr) { // Each item ID is the item's index into the gItems array, // plus one because a value of 0 is invalid (it's kDataBrowserNoItem). for (itemIndex = 0; itemIndex < itemCount; itemIndex++) { itemsIDArray[itemIndex] = (DataBrowserItemID) (itemIndex + 1); } err = AddDataBrowserItems( gDataControl, kDataBrowserNoItem, // to root (UInt32) itemCount, itemsIDArray, kDataBrowserItemNoProperty ); } } // Clean up. CFQRelease(items); free(itemsIDArray); DisplayError(err); }
/* Changed ... Have to implement the same for translators */ void adddrivers_to_list (ControlRef widget, WindowRef dlg, BOOL addNotify) { wchar_t drvdesc[1024], drvattrs[1024], driver[1024]; DataBrowserItemID item = DBITEM_ID + 1; DataBrowserCallbacks dbCallbacks; ThemeDrawingState outState = NULL; UInt16 colSize[5] = { 150, 150, 100, 50 , 50}; void *handle; SInt16 outBaseline; Point ioBound; struct stat _stat; SQLSMALLINT len, len1; SQLRETURN ret; HENV henv, drv_henv; HDBC drv_hdbc; pSQLGetInfoFunc funcHdl; pSQLAllocHandle allocHdl; pSQLAllocEnv allocEnvHdl = NULL; pSQLAllocConnect allocConnectHdl = NULL; pSQLFreeHandle freeHdl; pSQLFreeEnv freeEnvHdl; pSQLFreeConnect freeConnectHdl; char *_drv_u8 = NULL; int i; if (!widget) return; GetThemeDrawingState (&outState); /* Install an event handler on the component databrowser */ dbCallbacks.version = kDataBrowserLatestCallbacks; InitDataBrowserCallbacks (&dbCallbacks); if (addNotify) dbCallbacks.u.v1.itemNotificationCallback = NewDataBrowserItemNotificationUPP (drivers_notification_item); /* On Mac OS X 10.0.x : clientDataCallback */ dbCallbacks.u.v1.itemDataCallback = NewDataBrowserItemDataUPP (drivers_getset_item); SetDataBrowserCallbacks (widget, &dbCallbacks); /* Begin the draw of the data browser */ SetDataBrowserTarget (widget, DBITEM_ID); /* Make the clean up */ for (i = 0; i < Drivers_nrows; i++, item++) { CFRelease (Drivers_array[0][i]); Drivers_array[0][i] = NULL; CFRelease (Drivers_array[1][i]); Drivers_array[1][i] = NULL; CFRelease (Drivers_array[2][i]); Drivers_array[2][i] = NULL; CFRelease (Drivers_array[3][i]); Drivers_array[3][i] = NULL; CFRelease (Drivers_array[4][i]); Drivers_array[4][i] = NULL; RemoveDataBrowserItems (widget, DBITEM_ID, 1, &item, DBNAME_ID); } /* Global Initialization */ Drivers_nrows = 0; item = DBITEM_ID + 1; /* Create a HENV to get the list of drivers then */ ret = SQLAllocHandle (SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv); if (ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO) { _iodbcdm_nativeerrorbox (dlg, henv, SQL_NULL_HANDLE, SQL_NULL_HANDLE); goto end; } /* Set the version ODBC API to use */ SQLSetEnvAttr (henv, SQL_ATTR_ODBC_VERSION, (SQLPOINTER) SQL_OV_ODBC3, SQL_IS_UINTEGER); /* Get the list of drivers */ ret = SQLDriversW (henv, SQL_FETCH_FIRST, drvdesc, sizeof (drvdesc)/sizeof(wchar_t), &len, drvattrs, sizeof (drvattrs)/sizeof(wchar_t), &len1); if (ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO && ret != SQL_NO_DATA) { _iodbcdm_nativeerrorbox (dlg, henv, SQL_NULL_HANDLE, SQL_NULL_HANDLE); goto error; } while (ret != SQL_NO_DATA) { Drivers_array[0][Drivers_nrows] = convert_wchar_to_CFString(drvdesc); /* Get the driver library name */ SQLSetConfigMode (ODBC_BOTH_DSN); SQLGetPrivateProfileStringW (drvdesc, L"Driver", L"", driver, sizeof (driver)/sizeof(wchar_t), L"odbcinst.ini"); if (driver[0] == L'\0') SQLGetPrivateProfileStringW (L"Default", L"Driver", L"", driver, sizeof (driver)/sizeof(wchar_t), L"odbcinst.ini"); if (driver[0] == L'\0') { if (Drivers_array[0][Drivers_nrows]) { CFRelease (Drivers_array[0][Drivers_nrows]); Drivers_array[0][Drivers_nrows] = NULL; } goto skip; } Drivers_array[1][Drivers_nrows] = convert_wchar_to_CFString(driver); /* Alloc a connection handle */ drv_hdbc = NULL; drv_henv = NULL; _drv_u8 = (char *) dm_SQL_WtoU8((SQLWCHAR*)driver, SQL_NTS); if (_drv_u8 == NULL) goto skip; if ((handle = DLL_OPEN(_drv_u8)) != NULL) { if ((allocHdl = (pSQLAllocHandle)DLL_PROC(handle, "SQLAllocHandle")) != NULL) { ret = allocHdl(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &drv_henv); if (ret == SQL_ERROR) goto nodriverver; ret = allocHdl(SQL_HANDLE_DBC, drv_henv, &drv_hdbc); if (ret == SQL_ERROR) goto nodriverver; } else { if ((allocEnvHdl = (pSQLAllocEnv)DLL_PROC(handle, "SQLAllocEnv")) != NULL) { ret = allocEnvHdl(&drv_henv); if (ret == SQL_ERROR) goto nodriverver; } else goto nodriverver; if ((allocConnectHdl = (pSQLAllocConnect)DLL_PROC(handle, "SQLAllocConnect")) != NULL) { ret = allocConnectHdl(drv_henv, &drv_hdbc); if (ret == SQL_ERROR) goto nodriverver; } else goto nodriverver; } /* * Use SQLGetInfoA for Unicode drivers * and SQLGetInfo for ANSI drivers */ funcHdl = (pSQLGetInfoFunc)DLL_PROC(handle, "SQLGetInfoA"); if (!funcHdl) funcHdl = (pSQLGetInfoFunc)DLL_PROC(handle, "SQLGetInfo"); if (funcHdl) { /* Retrieve some informations */ ret = funcHdl (drv_hdbc, SQL_DRIVER_VER, drvattrs, sizeof(drvattrs), &len); if (ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO) { char *p = drvattrs; /* Find the description if one provided */ for (; *p ; p++) { if (*p == ' ') { *p++ = '\0'; break; } } /* * Store Version */ Drivers_array[2][Drivers_nrows] = CFStringCreateWithCString(NULL, (char *)drvattrs, kCFStringEncodingUTF8); } else goto nodriverver; } else if ((funcHdl = (pSQLGetInfoFunc)DLL_PROC(handle, "SQLGetInfoW")) != NULL) { /* Retrieve some informations */ ret = funcHdl (drv_hdbc, SQL_DRIVER_VER, drvattrs, sizeof(drvattrs), &len); if (ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO) { wchar_t *p = drvattrs; /* Find the description if one provided */ for (; *p ; p++) { if (*p == L' ') { *p++ = L'\0'; break; } } /* * Store Version */ Drivers_array[2][Drivers_nrows] = convert_wchar_to_CFString(drvattrs); } else goto nodriverver; } else goto nodriverver; } else { nodriverver: Drivers_array[2][Drivers_nrows] = CFStringCreateWithCString(NULL, "##.##", kCFStringEncodingUTF8); } if(drv_hdbc || drv_henv) { if(allocConnectHdl && (freeConnectHdl = (pSQLFreeConnect)DLL_PROC(handle, "SQLFreeConnect")) != NULL) { freeConnectHdl(drv_hdbc); drv_hdbc = NULL; } if(allocEnvHdl && (freeEnvHdl = (pSQLFreeEnv)DLL_PROC(handle, "SQLFreeEnv")) != NULL) { freeEnvHdl(drv_henv); drv_henv = NULL; } } if ((drv_hdbc || drv_henv) && (freeHdl = (pSQLFreeHandle)DLL_PROC(handle, "SQLFreeHandle")) != NULL) { if(drv_hdbc) freeHdl(SQL_HANDLE_DBC, drv_hdbc); if(drv_henv) freeHdl(SQL_HANDLE_ENV, drv_henv); } DLL_CLOSE(handle); /* Get the size and date of the driver */ if (!stat (_drv_u8, &_stat)) { CFStringRef strRef; struct tm drivertime; char buf[100]; Drivers_array[3][Drivers_nrows] = CFStringCreateWithFormat(NULL, NULL, strRef = CFStringCreateWithCString(NULL, "%d Kb", kCFStringEncodingUTF8), (int) (_stat.st_size / 1024)); CFRelease(strRef); localtime_r (&_stat.st_mtime, &drivertime); strftime (buf, sizeof (buf), "%c", &drivertime); Drivers_array[4][Drivers_nrows] = CFStringCreateWithCString(NULL, buf, kCFStringEncodingUTF8); } else { Drivers_array[3][Drivers_nrows] = CFStringCreateWithCString(NULL, "-", kCFStringEncodingUTF8); Drivers_array[4][Drivers_nrows] = CFStringCreateWithCString(NULL, "-", kCFStringEncodingUTF8); } for(i = 0 ; i < 5 ; i++) { GetThemeTextDimensions (Drivers_array[i][Drivers_nrows], kThemeSystemFont, kThemeStateActive, false, &ioBound, &outBaseline); if(colSize[i] < ioBound.h) colSize[i] = ioBound.h; } AddDataBrowserItems (widget, DBITEM_ID, 1, &item, DBNAME_ID); item++; Drivers_nrows++; /* Process next one */ skip: MEM_FREE (_drv_u8); _drv_u8 = NULL; ret = SQLDriversW (henv, SQL_FETCH_NEXT, drvdesc, sizeof (drvdesc)/sizeof(wchar_t), &len, drvattrs, sizeof (drvattrs)/sizeof(wchar_t), &len1); if (ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO && ret != SQL_NO_DATA) { _iodbcdm_nativeerrorbox (dlg, henv, SQL_NULL_HANDLE, SQL_NULL_HANDLE); goto error; } } error: /* Clean all that */ SQLFreeHandle (SQL_HANDLE_ENV, henv); end: ActivateControl (widget); /* Resize the columns to have a good look */ SetDataBrowserTableViewNamedColumnWidth (widget, DBNAME_ID, colSize[0] + 20); SetDataBrowserTableViewNamedColumnWidth (widget, DBFILE_ID, colSize[1] + 20); SetDataBrowserTableViewNamedColumnWidth (widget, DBVERSION_ID, colSize[2] + 20); SetDataBrowserTableViewNamedColumnWidth (widget, DBSIZE_ID, colSize[3] + 20); SetDataBrowserTableViewNamedColumnWidth (widget, DBDATE_ID, colSize[4] + 20); DrawOneControl (widget); /* Remove the DataBrowser callback */ SetDataBrowserCallbacks (NULL, &dbCallbacks); if(outState) DisposeThemeDrawingState (outState); }
int main(int argc, char* argv[]) { IBNibRef nibRef; OSStatus err; glob_t g; // check the correct BASS was loaded if (HIWORD(BASS_GetVersion())!=BASSVERSION) { Error("An incorrect version of BASS was loaded"); return 0; } // initialize default output device if (!BASS_Init(-1,44100,0,NULL,NULL)) { Error("Can't initialize device"); return 0; } // Create Window and stuff err = CreateNibReference(CFSTR("plugins"), &nibRef); if (err) return err; err = CreateWindowFromNib(nibRef, CFSTR("Window"), &win); if (err) return err; DisposeNibReference(nibRef); DataBrowserCallbacks dbc; dbc.version=kDataBrowserLatestCallbacks; InitDataBrowserCallbacks(&dbc); dbc.u.v1.itemDataCallback=MyDataBrowserItemDataCallback; ControlRef list=GetControl(20); SetDataBrowserCallbacks(list,&dbc); { // look for plugins (in the executable directory) char path[300]; DWORD l=sizeof(path); _NSGetExecutablePath(path,&l); strcpy(strrchr(path,'/')+1,"libbass*.dylib"); if (!glob(path,0,0,&g)) { int a; for (a=0;a<g.gl_pathc;a++) { if (BASS_PluginLoad(g.gl_pathv[a],0)) { // plugin loaded, add it to the list... char *p=strrchr(g.gl_pathv[a],'/')+1; AddDataBrowserItems(list,kDataBrowserNoItem,1,(DataBrowserItemID*)&p,kDataBrowserItemNoProperty); } } } DWORD c; GetDataBrowserItemCount(list,kDataBrowserNoItem,FALSE,kDataBrowserItemNoState,(DataBrowserItemState*)&c); if (!c) { // no plugins... static const char *noplugins="no plugins - visit the BASS webpage to get some"; AddDataBrowserItems(list,kDataBrowserNoItem,1,(DataBrowserItemID*)&noplugins,kDataBrowserItemNoProperty); } } SetupControlHandler(10,kEventControlHit,OpenEventHandler); SetControlAction(GetControl(12),NewControlActionUPP(PosEventHandler)); EventLoopTimerRef timer; InstallEventLoopTimer(GetCurrentEventLoop(),kEventDurationNoWait,kEventDurationSecond/2,NewEventLoopTimerUPP(TimerProc),0,&timer); ShowWindow(win); RunApplicationEventLoop(); globfree(&g); // "free" the output device and all plugins BASS_Free(); BASS_PluginFree(0); return 0; }
void AddServiceToList(char * url, DataBrowserItemID parentID) { CFMutableStringRef serviceType; char tempServiceString[kMaxTypeNameLength]; char * svcString = NULL; UInt16 svcLen; DataBrowserItemID itemID; CFComparisonResult result = -1; int i; CFStringRef tempURL; OSStatus err; if (url) { err = NSLGetServiceFromURL(url, &svcString, &svcLen); if (err == noErr) { strncpy(tempServiceString, svcString, svcLen); tempServiceString[svcLen] = '\0'; // Convert to lowercase so we can do a compare. for (i = 0; i < svcLen; i++) tempServiceString[i] = tolower(tempServiceString[i]); // Gets the current value of the service type from the popup menu. GetServiceTypeToLookup(&serviceType, NULL); // Make sure we're only adding items for the service type that's selected in the popup menu. if (strcmp(CFStringGetCStringPtr(serviceType, CFStringGetSystemEncoding()), tempServiceString) == 0) { // Check if we're under the limit for maximum services per neighborhood. if (gNeighborhoodInfo.neighborhoodSize[parentID - 1] < kMaxServicesPerNeighborhood) { // Check if the item is already in our list. If it is, "result" will be 0. for (i = 0; i < gNeighborhoodInfo.neighborhoodSize[parentID - 1]; i++) { tempURL = CFStringCreateWithCString(NULL, url, CFStringGetSystemEncoding()); if (tempURL) { result = CFStringCompare(tempURL, gData[kMaxServicesPerNeighborhood*(parentID-1)+kMaxNeighborhoods+i], kCFCompareCaseInsensitive); CFRelease(tempURL); if (result == kCFCompareEqualTo) break; } } // As long as the item isn't in the list and the DataBrowser container is open, add the item. if (result != kCFCompareEqualTo && gNeighborhoodInfo.isNeighborhoodOpen[parentID - 1] && gNeighborhoodInfo.isNeighborhoodVisible[parentID - 1]) { // Increment the count of the services in this neighborhood. gNeighborhoodInfo.neighborhoodSize[parentID - 1]++; itemID = kMaxServicesPerNeighborhood * (parentID - 1) + kMaxNeighborhoods + gNeighborhoodInfo.neighborhoodSize[parentID - 1]; gData[itemID - 1] = CFStringCreateWithCString(NULL, url, CFStringGetSystemEncoding()); AddDataBrowserItems(gDataBrowserControl, parentID, 1, &itemID, kNameColumn); } } } } free(url); } }
bool refreshInfoWin(const CDecoder *pDec) { OSStatus iResult; UInt32 i, j; if (!g_bLoaded) { return false; } /* Clean up any previous contents */ clearInfoWin(); /* Load new contents */ g_iNumTags = pDec->getNumTags(); if (NULL == (g_psTags = new CFStringRef[2 * g_iNumTags])) { g_iNumTags = 0; fprintf(stderr, "refreshInfoWin() - g_psTags allocation failed!\n"); return false; } for (i = 0; i < g_iNumTags; i++) { if (NULL == (g_psTags[2 * i] = pDec->getTagName(i))) { for (j = 0; j < i; j++) { CFRelease(g_psTags[2 * i]); CFRelease(g_psTags[(2 * i) + 1]); } delete[] g_psTags; g_psTags = NULL; g_iNumTags = 0; fprintf(stderr, "refreshInfoWin() - pDec->getTagName() failed!\n"); return false; } if (NULL == (g_psTags[(2 * i) + 1] = pDec->getTagData(i))) { for (j = 0; j < i; j++) { CFRelease(g_psTags[2 * i]); CFRelease(g_psTags[(2 * i) + 1]); } delete[] g_psTags; g_psTags = NULL; g_iNumTags = 0; fprintf(stderr, "refreshInfoWin() - pDec->getTagData() failed!\n"); return false; } CFRetain(g_psTags[2 * i]); CFRetain(g_psTags[(2 * i) + 1]); } /* Load up the two text areas. */ ControlRef cRef; ControlID cID; cID.signature = FOUR_CHAR_CODE('finf'); cID.id = 14; if (noErr != (iResult = GetControlByID(g_refInfoWin, &cID, &cRef))) { clearInfoWin(); fprintf(stderr, "refreshInfoWin() - GetControlByID(finf) failed, returning %lu!\n", (unsigned long) iResult); return false; } if (!setTextBoxContents(cRef, pDec->getSource()->getInfoString())) { clearInfoWin(); fprintf(stderr, "refreshInfoWin() - setTextBoxContents(finf) failed!\n"); return false; } Draw1Control(cRef); cID.signature = FOUR_CHAR_CODE('dinf'); cID.id = 15; if (noErr != (iResult = GetControlByID(g_refInfoWin, &cID, &cRef))) { clearInfoWin(); fprintf(stderr, "refreshInfoWin() - GetControlByID(dinf) failed, returning %lu!\n", (unsigned long) iResult); return false; } if (!setTextBoxContents(cRef, pDec->getInfoString())) { clearInfoWin(); fprintf(stderr, "refreshInfoWin() - setTextBoxContents(dinf) failed!\n"); return false; } Draw1Control(cRef); /* Load up the browser control. */ cID.signature = FOUR_CHAR_CODE('tags'); cID.id = 16; if (noErr != (iResult = GetControlByID(g_refInfoWin, &cID, &cRef))) { clearInfoWin(); fprintf(stderr, "refreshInfoWin() - GetControlByID(tags) failed, returning %lu!\n", (unsigned long) iResult); return false; } if (noErr != (iResult = AddDataBrowserItems(cRef, kDataBrowserNoItem, g_iNumTags, NULL, kDataBrowserOrderIncreasing))) { clearInfoWin(); fprintf(stderr, "refreshInfoWin() - RemoveDataBrowserItems() failed, returning %lu!\n", (unsigned long) iResult); return false; } Draw1Control(cRef); return true; }
bool dialog_animation_settings_run(int animate_idx) { int i,pose_move_idx; ControlRef ctrl; ControlID ctrl_id; DataBrowserItemID itemID; DataBrowserCallbacks dbcall; DataBrowserItemDataUPP pose_list_item_upp,particle_list_item_upp,ring_list_item_upp; DataBrowserItemNotificationUPP pose_list_notify_upp,particle_list_notify_upp,ring_list_notify_upp; EventHandlerUPP event_upp,tab_event_upp; EventLoopTimerRef timer_event; EventLoopTimerUPP timer_upp; EventTypeSpec event_list[]={{kEventClassCommand,kEventProcessCommand}}, tab_event_list[]={{kEventClassCommand,kEventProcessCommand}, {kEventClassControl,kEventControlHit}}; // backup animation for cancel memmove(&animate_backup,&model.animates[animate_idx],sizeof(model_animate_type)); // if there is no pose moves or new animation, // then we need to add a default pose pose_move_idx=0; if (model.animates[animate_idx].npose_move==0) { pose_move_idx=model_animate_pose_insert(&model,animate_idx,-1,0); } // open the dialog dialog_open(&dialog_animation_settings_wind,"AnimationSettings"); // tab dialog_set_tab(dialog_animation_settings_wind,kAnimationPoseTab,0,0,kAnimationPoseTabCount); ctrl_id.signature=kAnimationPoseTab; ctrl_id.id=0; GetControlByID(dialog_animation_settings_wind,&ctrl_id,&ctrl); tab_event_upp=NewEventHandlerUPP(pose_move_setting_tab_proc); InstallControlEventHandler(ctrl,tab_event_upp,GetEventTypeCount(tab_event_list),tab_event_list,dialog_animation_settings_wind,NULL); // set pose list dialog_animate_idx=animate_idx; dialog_pose_move_idx=pose_move_idx; ctrl_id.signature=kAnimationPoseList; ctrl_id.id=0; GetControlByID(dialog_animation_settings_wind,&ctrl_id,&dialog_pose_move_list); dbcall.version=kDataBrowserLatestCallbacks; InitDataBrowserCallbacks(&dbcall); pose_list_item_upp=NewDataBrowserItemDataUPP(&pose_list_item_proc); dbcall.u.v1.itemDataCallback=pose_list_item_upp; pose_list_notify_upp=NewDataBrowserItemNotificationUPP(&pose_list_notify_proc); dbcall.u.v1.itemNotificationCallback=pose_list_notify_upp; SetDataBrowserCallbacks(dialog_pose_move_list,&dbcall); AddDataBrowserItems(dialog_pose_move_list,kDataBrowserNoItem,model.animates[dialog_animate_idx].npose_move,NULL,kDataBrowserItemNoProperty); dialog_pose_move_change_ok=FALSE; itemID=pose_move_idx+1; SetDataBrowserSelectedItems(dialog_pose_move_list,1,&itemID,kDataBrowserItemsAssign); dialog_pose_move_change_ok=TRUE; // setup particle list ctrl_id.signature=kAnimationParticleList; ctrl_id.id=0; GetControlByID(dialog_animation_settings_wind,&ctrl_id,&dialog_particle_list); dbcall.version=kDataBrowserLatestCallbacks; InitDataBrowserCallbacks(&dbcall); particle_list_item_upp=NewDataBrowserItemDataUPP(&particle_list_item_proc); dbcall.u.v1.itemDataCallback=particle_list_item_upp; particle_list_notify_upp=NewDataBrowserItemNotificationUPP(&particle_list_notify_proc); dbcall.u.v1.itemNotificationCallback=particle_list_notify_upp; SetDataBrowserCallbacks(dialog_particle_list,&dbcall); // setup ring list ctrl_id.signature=kAnimationRingList; ctrl_id.id=0; GetControlByID(dialog_animation_settings_wind,&ctrl_id,&dialog_ring_list); dbcall.version=kDataBrowserLatestCallbacks; InitDataBrowserCallbacks(&dbcall); ring_list_item_upp=NewDataBrowserItemDataUPP(&ring_list_item_proc); dbcall.u.v1.itemDataCallback=ring_list_item_upp; ring_list_notify_upp=NewDataBrowserItemNotificationUPP(&ring_list_notify_proc); dbcall.u.v1.itemNotificationCallback=ring_list_notify_upp; SetDataBrowserCallbacks(dialog_ring_list,&dbcall); // fill pose combo dialog_clear_combo(dialog_animation_settings_wind,kAnimationPosePose,0); for (i=0;i!=model.npose;i++) { dialog_add_combo_item(dialog_animation_settings_wind,kAnimationPosePose,0,model.poses[i].name,FOUR_CHAR_CODE('\?\?\?\?')); } // fill mesh combo (leave none in list) for (i=0;i!=model.nmesh;i++) { dialog_add_combo_item(dialog_animation_settings_wind,kAnimationMeshName,0,model.meshes[i].name,FOUR_CHAR_CODE('\?\?\?\?')); } // load setting data dialog_set_text(dialog_animation_settings_wind,kAnimationName,0,model.animates[animate_idx].name); dialog_set_boolean(dialog_animation_settings_wind,kAnimationLoop,0,model.animates[animate_idx].loop); dialog_set_focus(dialog_animation_settings_wind,kAnimationName,0); // load pose move data dialog_pose_move_settings_load(); dialog_animation_settings_cancel=FALSE; // show window ShowWindow(dialog_animation_settings_wind); // install event handler event_upp=NewEventHandlerUPP(animation_settings_event_proc); InstallWindowEventHandler(dialog_animation_settings_wind,event_upp,GetEventTypeCount(event_list),event_list,NULL,NULL); // modal window and timer timer_upp=NewEventLoopTimerUPP(pose_move_timer); InstallEventLoopTimer(GetCurrentEventLoop(),0,0.01,timer_upp,NULL,&timer_event); RunAppModalLoopForWindow(dialog_animation_settings_wind); RemoveEventLoopTimer(timer_event); DisposeEventLoopTimerUPP(timer_upp); // dialog to data dialog_get_text(dialog_animation_settings_wind,kAnimationName,0,model.animates[animate_idx].name,name_str_len); model.animates[animate_idx].loop=dialog_get_boolean(dialog_animation_settings_wind,kAnimationLoop,0); dialog_pose_move_settings_save(); // close window DisposeDataBrowserItemDataUPP(pose_list_item_upp); DisposeDataBrowserItemNotificationUPP(pose_list_notify_upp); DisposeDataBrowserItemDataUPP(particle_list_item_upp); DisposeDataBrowserItemNotificationUPP(particle_list_notify_upp); DisposeDataBrowserItemDataUPP(ring_list_item_upp); DisposeDataBrowserItemNotificationUPP(ring_list_notify_upp); DisposeWindow(dialog_animation_settings_wind); // if cancel, reset animation if (dialog_animation_settings_cancel) { memmove(&model.animates[animate_idx],&animate_backup,sizeof(model_animate_type)); } reset_animate_list(); return(!dialog_animation_settings_cancel); }
void addfdsns_to_list (TDSNCHOOSER *dsnchoose_t, char *path, Boolean b_reset) { DataBrowserItemID item = DBITEM_ID + 1; DataBrowserCallbacks dbCallbacks; ThemeDrawingState outState = NULL; UInt16 colSize[3] = { 400, 100, 150 }; SInt16 outBaseline; Point ioBound; int i; DIR *dir; char *path_buf; struct dirent *dir_entry; struct stat fstat; int b_added; ControlRef widget; WindowRef dlg; if (!dsnchoose_t || !path) return; widget = dsnchoose_t->fdsnlist; dlg = dsnchoose_t->mainwnd; GetThemeDrawingState (&outState); /* Install an event handler on the component databrowser */ dbCallbacks.version = kDataBrowserLatestCallbacks; InitDataBrowserCallbacks (&dbCallbacks); dbCallbacks.u.v1.itemNotificationCallback = NewDataBrowserItemNotificationUPP (fdsn_notification_item); /* On Mac OS X 10.0.x : clientDataCallback */ dbCallbacks.u.v1.itemDataCallback = NewDataBrowserItemDataUPP (fdsn_getset_item); SetDataBrowserCallbacks (widget, &dbCallbacks); /* Begin the draw of the data browser */ SetDataBrowserTarget (widget, DBITEM_ID); /* Make the clean up */ for (i = 0; i < FDSN_nrows; i++, item++) { CFRelease (FDSN_array[i]); FDSN_array[i] = NULL; FDSN_type[i] = 0; RemoveDataBrowserItems (widget, DBITEM_ID, 1, &item, DBNAME_ID); } ActivateControl (widget); DrawOneControl (widget); /* Global Initialization */ FDSN_nrows = 0; item = DBITEM_ID + 1; if ((dir = opendir (path))) { while ((dir_entry = readdir (dir)) && FDSN_nrows < MAX_ROWS) { asprintf (&path_buf, "%s/%s", path, dir_entry->d_name); b_added = 0; if (stat ((LPCSTR) path_buf, &fstat) >= 0 && S_ISDIR (fstat.st_mode)) { if (dir_entry->d_name && dir_entry->d_name[0] != '.') { FDSN_array[FDSN_nrows] = CFStringCreateWithCString(NULL, dir_entry->d_name, kCFStringEncodingUTF8); FDSN_type[FDSN_nrows] = 0; b_added = 1; } } else if (stat ((LPCSTR) path_buf, &fstat) >= 0 && !S_ISDIR (fstat.st_mode) && strstr (dir_entry->d_name, ".dsn")) { FDSN_array[FDSN_nrows] = CFStringCreateWithCString(NULL, dir_entry->d_name, kCFStringEncodingUTF8); FDSN_type[FDSN_nrows] = 1; b_added = 1; } if (path_buf) free (path_buf); if (b_added) { GetThemeTextDimensions (FDSN_array[FDSN_nrows], kThemeSystemFont, kThemeStateActive, false, &ioBound, &outBaseline); if(colSize[0] < ioBound.h) colSize[0] = ioBound.h; AddDataBrowserItems (widget, DBITEM_ID, 1, &item, DBNAME_ID); item++; FDSN_nrows++; } } /* Close the directory entry */ closedir (dir); } else create_error (NULL, NULL, "Error during accessing directory information", strerror (errno)); ActivateControl (widget); /* Resize the columns to have a good look */ SetDataBrowserTableViewNamedColumnWidth (widget, DBNAME_ID, colSize[0] + 20); DrawOneControl (widget); /* Remove the DataBrowser callback */ SetDataBrowserCallbacks (NULL, &dbCallbacks); if(outState) DisposeThemeDrawingState (outState); if (b_reset) SetDataBrowserScrollPosition(widget, 0, 0); fill_dir_menu(dsnchoose_t, path); }