bool wxSound::Create(const wxString& fileName, bool isResource) { Stop(); if (isResource) { #ifdef __WXMAC__ m_type = wxSound_RESOURCE; Str255 lpSnd ; wxMacStringToPascal( fileName , lpSnd ) ; m_sndname = fileName; m_hSnd = (char*) GetNamedResource('snd ', (const unsigned char *) lpSnd); #else return false; #endif } else { m_type = wxSound_FILE; m_sndname = fileName; } return true; }
Handle getnamedresource(ResType theType, const char *name) { char localStr[256]; strcpy(localStr,name); my_c2pstr(localStr); return GetNamedResource(theType,(StringPtr)localStr); }
wxOSXSoundManagerSoundData::wxOSXSoundManagerSoundData(const wxString& fileName) : m_pSndChannel(NULL) { Str255 lpSnd ; wxMacStringToPascal( fileName , lpSnd ) ; m_hSnd = (SndListHandle) GetNamedResource('snd ', (const unsigned char *) lpSnd); }
short GetColorMenuResID( short menuItem ) { Handle h; Str255 menuText; short resID; ResType resType; GetMenuItemText( colorMenu, menuItem, menuText ); h = GetNamedResource( 'HEct', menuText ); if( h ) { GetResInfo( h, &resID, &resType, menuText ); return resID; } else return( CM_StartingResourceID ); }
//don't know what to do with looped, wth bool wxSound::DoPlay(unsigned flags) const { bool ret = false; if (m_isResource) { Str255 snd ; wxMacStringToPascal( m_sndname , snd ) ; SndListHandle hSnd; hSnd = (SndListHandle) GetNamedResource('snd ', snd); if ((hSnd != NULL) && (SndPlay((SndChannelPtr)m_sndChan, (SndListHandle) hSnd, (flags & wxSOUND_ASYNC)) == noErr)) ret = true; } return ret; }
static PyObject *Res_GetNamedResource(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Handle _rv; ResType theType; Str255 name; #ifndef GetNamedResource PyMac_PRECHECK(GetNamedResource); #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetOSType, &theType, PyMac_GetStr255, name)) return NULL; _rv = GetNamedResource(theType, name); { OSErr _err = ResError(); if (_err != noErr) return PyMac_Error(_err); } _res = Py_BuildValue("O&", ResObj_New, _rv); return _res; }
void PlayResource (const TCHAR* lpName) { LKASSERT(lpName); if(!lpName || !bSoundFile || !bSoundInit || !EnableSoundModes) { return; } // Check if AudioChunk is already loaded. auto ib = audioChunkCache.insert(std::make_pair(lpName, nullptr)); if(ib.second) { // Load AudioChunk ConstBuffer<void> sndBuffer = GetNamedResource(lpName); if(!sndBuffer.IsEmpty()) { SDL_RWops* SndBuffer = SDL_RWFromConstMem(sndBuffer.data, sndBuffer.size); if(SndBuffer) { ib.first->second = Mix_LoadWAV_RW(SndBuffer, 1); } } } if(ib.first->second) { Mix_PlayChannel(-1, ib.first->second, 0); } }
void mac_speaker (struct obj *instr, char *melody) { SndChannelPtr theChannel = (SndChannelPtr) 0; SndCommand theCmd; Handle theSound; unsigned char theName [32]; char *n = (char *) &theName [1]; int typ = instr->otyp; const char *actualn = OBJ_NAME (objects [typ]); /* * First: are we in the library ? */ if (flags.silent) { return; } /* * Is this a known instrument ? */ strcpy (n, actualn); theName [0] = strlen (n); theSound = GetNamedResource ('snd ', theName); if (! theSound) { return; } HLock (theSound); /* * Set up the synth */ if (SndNewChannel(&theChannel, sampledSynth, initMono + initNoInterp, (void *) 0) == noErr) { char midi_note [] = {57, 59, 60, 62, 64, 65, 67}; short err; short snd_len = SND_LEN (theSound) / 18; theCmd.cmd = soundCmd; theCmd.param1 = 0; theCmd.param2 = (long) SND_BUFFER (theSound); err = SndDoCommand (theChannel, &theCmd, false); /* * We rack 'em up all in a row * The mac will play them correctly and then end, since * we do a sync close below. * */ while (*melody && ! err) { while (*melody > 'G') { *melody -= 8; } while (*melody < 'A') { *melody += 8; } theCmd.cmd = freqDurationCmd; theCmd.param1 = snd_len; theCmd.param2 = midi_note [*melody - 'A']; err = SndDoCommand (theChannel, &theCmd, false); melody ++; } SndDisposeChannel (theChannel, false); /* Sync wait for completion */ ReleaseResource (theSound); } }
bool wxIcon::LoadFile( const wxString& filename, wxBitmapType type, int desiredWidth, int desiredHeight ) { UnRef(); if ( type == wxBITMAP_TYPE_ICON_RESOURCE ) { OSType theId = 0 ; if ( filename == wxT("wxICON_INFORMATION") ) { theId = kAlertNoteIcon ; } else if ( filename == wxT("wxICON_QUESTION") ) { theId = kAlertCautionIcon ; } else if ( filename == wxT("wxICON_WARNING") ) { theId = kAlertCautionIcon ; } else if ( filename == wxT("wxICON_ERROR") ) { theId = kAlertStopIcon ; } else { #if 0 Str255 theName ; OSType theType ; wxMacStringToPascal( name , theName ) ; Handle resHandle = GetNamedResource( 'cicn' , theName ) ; if ( resHandle != 0L ) { GetResInfo( resHandle , &theId , &theType , theName ) ; ReleaseResource( resHandle ) ; } #endif } if ( theId != 0 ) { IconRef iconRef = NULL ; verify_noerr( GetIconRef( kOnSystemDisk, kSystemIconsCreator, theId, &iconRef ) ) ; if ( iconRef ) { m_refData = new wxIconRefData( (WXHICON) iconRef ) ; return true ; } } return false ; } else { wxBitmapHandler *handler = wxBitmap::FindHandler( type ); if ( handler ) { wxBitmap bmp ; if ( handler->LoadFile( &bmp , filename, type, desiredWidth, desiredHeight )) { CopyFromBitmap( bmp ) ; return true ; } return false ; } else { #if wxUSE_IMAGE wxImage loadimage( filename, type ); if (loadimage.Ok()) { if ( desiredWidth == -1 ) desiredWidth = loadimage.GetWidth() ; if ( desiredHeight == -1 ) desiredHeight = loadimage.GetHeight() ; if ( desiredWidth != loadimage.GetWidth() || desiredHeight != loadimage.GetHeight() ) loadimage.Rescale( desiredWidth , desiredHeight ) ; wxBitmap bmp( loadimage ); CopyFromBitmap( bmp ) ; return true; } #endif } } return true ; }
Pixmap TkpGetNativeAppBitmap( Display *display, /* The display. */ CONST char *name, /* The name of the bitmap. */ int *width, /* The width & height of the bitmap. */ int *height) { Pixmap pix; CGrafPtr savePort; Boolean portChanged; Rect destRect; Handle resource; int type = -1, destWrote; Str255 nativeName; Tcl_Encoding encoding; /* * macRoman is the encoding that the resource fork uses. */ encoding = Tcl_GetEncoding(NULL, "macRoman"); Tcl_UtfToExternal(NULL, encoding, name, strlen(name), 0, NULL, (char *) &nativeName[1], 255, NULL, &destWrote, NULL); nativeName[0] = destWrote; Tcl_FreeEncoding(encoding); resource = GetNamedResource('cicn', nativeName); if (resource != NULL) { type = TYPE3; } else { resource = GetNamedResource('ICON', nativeName); if (resource != NULL) { type = TYPE2; } } if (resource == NULL) { return (Pixmap) NULL; } pix = Tk_GetPixmap(display, None, 32, 32, 0); portChanged = QDSwapPort(TkMacOSXGetDrawablePort(pix), &savePort); SetRect(&destRect, 0, 0, 32, 32); if (type == TYPE2) { RGBColor black = {0, 0, 0}; RGBForeColor(&black); PlotIcon(&destRect, resource); ReleaseResource(resource); } else if (type == TYPE3) { RGBColor white = {0xFFFF, 0xFFFF, 0xFFFF}; short id; ResType theType; Str255 dummy; /* * We need to first paint the background white. Also, for some reason * we *must* use GetCIcon instead of GetNamedResource for PlotCIcon to * work - so we use GetResInfo to get the id. */ RGBForeColor(&white); PaintRect(&destRect); GetResInfo(resource, &id, &theType, dummy); ReleaseResource(resource); resource = (Handle) GetCIcon(id); PlotCIcon(&destRect, (CIconHandle) resource); DisposeCIcon((CIconHandle) resource); } *width = 32; *height = 32; if (portChanged) { QDSwapPort(savePort, NULL); } return pix; }