Exemplo n.º 1
0
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);
}
Exemplo n.º 2
0
void
RemoveServicesFromNeighborhood(DataBrowserItemID parentID, Boolean removeFromDataBrowser)
{
    UInt32 i, itemID;
        
    // Only remove items if the neighborhood actually has items in it.
    if (gNeighborhoodInfo.neighborhoodSize[parentID - 1] > 0)
    {
        if (removeFromDataBrowser)
        {
            // Remove all items from the specified neighborhood.
            RemoveDataBrowserItems(gDataBrowserControl, parentID, 0, NULL, kDataBrowserItemNoProperty);
        }
            
        // Free all the memory allocated to store the URLs.
        for (i = 0; i < gNeighborhoodInfo.neighborhoodSize[parentID - 1]; i++)
        {
            itemID = kMaxServicesPerNeighborhood * (parentID - 1) + kMaxNeighborhoods + i;
            if (gData[itemID]) CFRelease(gData[itemID]);
        }
        
        // Reset the count for this neighborhood to 0.
        gNeighborhoodInfo.neighborhoodSize[parentID - 1] = 0;
    }
}
Exemplo n.º 3
0
OSStatus wxMacDataBrowserControl::RemoveItems(
    DataBrowserItemID container,
    UInt32 numItems,
    const DataBrowserItemID *items,
    DataBrowserPropertyID preSortProperty )
{
    return RemoveDataBrowserItems( m_controlRef, container, numItems, items, preSortProperty );
}
Exemplo n.º 4
0
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);
}
Exemplo n.º 5
0
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);
}
Exemplo n.º 6
0
static void DeleteCheatItem (void)
{
	OSStatus	err;
	HIViewRef	ctl, root;
	HIViewID	cid;
	Handle		selectedItems;
	ItemCount	selectionCount;

	selectedItems = NewHandle(0);
	if (!selectedItems)
		return;

	err = GetDataBrowserItems(dbRef, kDataBrowserNoItem, true, kDataBrowserItemIsSelected, selectedItems);
	selectionCount = (GetHandleSize(selectedItems) / sizeof(DataBrowserItemID));

	if (selectionCount == 0)
	{
		DisposeHandle(selectedItems);
		return;
	}

	err = RemoveDataBrowserItems(dbRef, kDataBrowserNoItem, selectionCount, (DataBrowserItemID *) *selectedItems, kDataBrowserItemNoProperty);

	for (unsigned int i = 0; i < selectionCount; i++)
	{
		citem[((DataBrowserItemID *) (*selectedItems))[i] - 1].valid   = false;
		citem[((DataBrowserItemID *) (*selectedItems))[i] - 1].enabled = false;
		numofcheats--;
	}

	DisposeHandle(selectedItems);

	root = HIViewGetRoot(wRef);
	cid.id = 0;

	if (numofcheats < MAC_MAX_CHEATS)
	{
		cid.signature = kNewButton;
		HIViewFindByID(root, cid, &ctl);
		err = ActivateControl(ctl);
	}

	if (numofcheats == 0)
	{
		cid.signature = kAllButton;
		HIViewFindByID(root, cid, &ctl);
		err = DeactivateControl(ctl);
	}
}
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);
}
Exemplo n.º 8
0
/* 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);
}
Exemplo n.º 9
0
bool clearInfoWin()
{
    OSStatus iResult;
    
    /* try to clear the control */

    ControlRef cRef;
    ControlID cID;

    cID.signature = FOUR_CHAR_CODE('finf');
    cID.id = 14;
    if (noErr != (iResult = GetControlByID(g_refInfoWin, &cID, &cRef)))
    {
        clearInfoWin();
        fprintf(stderr, "clearInfoWin() - GetControlByID(finf) failed, returning %lu!\n", (unsigned long) iResult);
        return false;
    }
    if (!setTextBoxContents(cRef, CFSTR("")))
    {
        clearInfoWin();
        fprintf(stderr, "clearInfoWin() - 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, "clearInfoWin() - GetControlByID(dinf) failed, returning %lu!\n", (unsigned long) iResult);
        return false;
    }
    if (!setTextBoxContents(cRef, CFSTR("")))
    {
        clearInfoWin();
        fprintf(stderr, "clearInfoWin() - setTextBoxContents(dinf) failed!\n");
        return false;
    }
    Draw1Control(cRef);
    
    cID.signature = FOUR_CHAR_CODE('tags');
    cID.id = 16;
    if (noErr != (iResult = GetControlByID(g_refInfoWin, &cID, &cRef)))
    {
        fprintf(stderr, "clearInfoWin() - GetControlByID(tags) failed, returning %lu!\n", (unsigned long) iResult);
        return false;
    }
    if (noErr != (iResult = RemoveDataBrowserItems(cRef, kDataBrowserNoItem, 0, NULL, kDataBrowserOrderIncreasing)))
    {
        fprintf(stderr, "clearInfoWin() - RemoveDataBrowserItems() failed, returning %lu!\n", (unsigned long) iResult);
        return false;
    }
    Draw1Control(cRef);

    /* clear memory */

    if (NULL != g_psTags)
    {
        for (UInt32 i = 0; i < (2 * g_iNumTags); i++)  {  CFRelease(g_psTags[i]);  }
        delete[] g_psTags;
        g_psTags = NULL;
        g_iNumTags = 0;
    }

    return true;
}
Exemplo n.º 10
0
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);
}