コード例 #1
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//	AUDiskStreamingCheckbox::AUDiskStreamingCheckbox
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
AUDiskStreamingCheckbox::AUDiskStreamingCheckbox (AUCarbonViewBase *inBase, 
				Point 					inLocation, 
				int 					inRightEdge, 
				ControlFontStyleRec & 	inFontStyle)
	: AUPropertyControl (inBase)
{
	Rect r;
	r.top = inLocation.v;		r.bottom = r.top + 16;
	r.left = inLocation.h;		r.right = r.left + inRightEdge;
	
	verify_noerr(CreateCheckBoxControl(mView->GetCarbonWindow(), 
										&r, 
										CFSTR("Disk Streaming"), 
										0, 
										true, 
										&mControl));
	verify_noerr (SetControlFontStyle (mControl, &inFontStyle));
	ControlSize smallSize = kControlSizeSmall;
	verify_noerr (SetControlData (mControl, kControlEntireControl, kControlSizeTag, sizeof (ControlSize), &smallSize));

	SInt16 baseLineOffset;
	verify_noerr (GetBestControlRect (mControl, &r, &baseLineOffset));
	r.bottom += baseLineOffset;
	SInt16 difference = (r.left + inRightEdge) - r.right;
	r.right += difference;
	r.left += difference;
	SetControlBounds (mControl, &r);
	EmbedControl(mControl);
	verify_noerr (AudioUnitAddPropertyListener(mView->GetEditAudioUnit(), kMusicDeviceProperty_StreamFromDisk, DiskStreamingListener, this));
	UInt32 value;
	UInt32 size = sizeof(value);
	verify_noerr (AudioUnitGetProperty (mView->GetEditAudioUnit(), kMusicDeviceProperty_StreamFromDisk, kAudioUnitScope_Global, 0, &value, &size));
	
	HandlePropertyChange (value);
	
	RegisterEvents();

}
コード例 #2
0
ファイル: AUCarbonViewControl.cpp プロジェクト: kdridi/acau
Boolean	AUCarbonViewControl::SizeControlToFit(ControlRef inControl, SInt16 *outWidth, SInt16 *outHeight)
{
#if !__LP64__
	if (inControl == 0) return false;
	
	Boolean bValue = false;
	// this only works on text controls -- returns an error for other controls, but doesn't do anything,
	// so the error is irrelevant
	SetControlData(inControl, kControlEntireControl, 'stim' /* kControlStaticTextIsMultilineTag */, sizeof(Boolean), &bValue);
	
	SInt16 baseLineOffset;
	Rect bestRect;
	OSErr err = GetBestControlRect(inControl, &bestRect, &baseLineOffset);  
	if (err != noErr) return false;
	
	int width = (bestRect.right - bestRect.left) + 1;
	int height = (bestRect.bottom - bestRect.top) + 1;
	
	Rect boundsRect;
	GetControlBounds (inControl, &boundsRect);
	
	Rect newRect;
	newRect.top = boundsRect.top;
	newRect.bottom = newRect.top + height;
	newRect.left = boundsRect.left;
	newRect.right = newRect.left + width;
	
	SetControlBounds (inControl, &newRect);
	
	if (outWidth)
		*outWidth = width;
	
	if (outHeight)
		*outHeight = height;
#endif	
	return true;
}
コード例 #3
0
void	AUControlGroup::AddAUInfo (		AUCarbonViewBase *			auView,
										const Point &				inLocation,
										const SInt16 				inRightOffset,
										const SInt16				inTotalWidth)
{
#if !__LP64__
   // get component info
	ComponentDescription desc;
    Handle h1 = NewHandleClear(4);
	OSStatus err = GetComponentInfo ((Component)auView->GetEditAudioUnit(), &desc, h1, 0, 0);

    if (err == noErr) {
        // Get the manufacturer's name... look for the ':' character convention
        HLock(h1);
        char* ptr1 = *h1;
        int len = *ptr1++;
        char* displayStr = 0;

        for (int i = 0; i < len; ++i) {
            if (ptr1[i] == ':') { // found the name
                ptr1[i++] = 0;
                displayStr = ptr1;
                break;
            }
        }

        // localize as necessary:
        if (!sLocalized) {
            CFBundleRef mainBundle = CFBundleGetBundleWithIdentifier(kLocalizedStringBundle_AUView);
            if (mainBundle) {
                kStringManufacturer = CFCopyLocalizedStringFromTableInBundle(
                                            kAUViewLocalizedStringKey_Manufacturer, kLocalizedStringTable_AUView,
                                            mainBundle, CFSTR("Manufacturer title string"));
                sLocalized = true;
            }
        }

        // display strings
        ControlRef newControl;
        Rect r;
        r.top = SInt16(inLocation.v);		r.bottom = SInt16(inLocation.v) + 16;
        ControlFontStyleRec fontStyle;
        fontStyle.flags = kControlUseFontMask | kControlUseJustMask;
        fontStyle.font = kControlFontSmallBoldSystemFont;

        // display manufacturer string
        if (displayStr) {
            CFMutableStringRef mfrstring = CFStringCreateMutable(NULL, 0);
            CFStringAppend(mfrstring, kStringManufacturer);		// "Manufacturer"
            CFStringAppend(mfrstring, kAUViewUnlocalizedString_TitleSeparator);
                                                                // "Manufacturer: "
            CFStringRef mfrname = CFStringCreateWithCString(NULL, displayStr, kCFStringEncodingUTF8);
            if (mfrname) {
                CFStringAppend(mfrstring, mfrname);	// "Manufacturer: MFRName"
                CFRelease (mfrname);
            }

            r.left = inLocation.h + inRightOffset;
			r.right = inLocation.h + inTotalWidth - 28;
			fontStyle.just = teFlushRight;

            verify_noerr(CreateStaticTextControl(auView->GetCarbonWindow(), &r, mfrstring, &fontStyle, &newControl));
            verify_noerr(auView->EmbedControl(newControl));
            CFRelease (mfrstring);

            //move displayStr ptr past the manu, to the name
            // we move the characters down an index, because the handle doesn't have any room
            // at the end for the \0
			int i = strlen(displayStr), j = 0;
			while (displayStr[++i] == ' ' && i < len)
				;
			while (i < len)
				displayStr[j++] = displayStr[i++];
			displayStr[j] = 0;
        } else {
			displayStr = ptr1;
			int i = 0, j = 0;
			do {
				displayStr[j] = displayStr[i];
				++j; ++i;
			} while (i < len);

			displayStr[j] = 0;
        }

        // display AudioUnit string
        r.left = inLocation.h;	r.right = r.left + inRightOffset;
        fontStyle.just = 0;

        CFMutableStringRef cfstr = CFStringCreateMutable(NULL, 0);
        CFStringAppend(cfstr, kAUViewLocalizedStringKey_AudioUnit);		// "Audio Unit"
        CFStringAppend(cfstr, kAUViewUnlocalizedString_TitleSeparator);
                                                        // "Audio Unit: "

		CFStringRef auname = CFStringCreateWithCString(NULL, displayStr, kCFStringEncodingUTF8);
		CFStringAppend(cfstr, auname);				// "Audio Unit: AUName"
		CFRelease (auname);

        verify_noerr(CreateStaticTextControl(auView->GetCarbonWindow(), &r, cfstr, &fontStyle, &newControl));

		// size text control correctly
		Boolean bValue = false;
		SetControlData(newControl, kControlEntireControl, 'stim' /* kControlStaticTextIsMultilineTag */, sizeof(Boolean), &bValue);
		SInt16 baseLineOffset;
		Rect bestRect;
		err = GetBestControlRect(newControl, &bestRect, &baseLineOffset);
		if (err == noErr)
		{
			int width = (bestRect.right - bestRect.left) + 1;
			int height = (bestRect.bottom - bestRect.top) + 1;
			SizeControl (newControl, width, height);
		}

        verify_noerr(auView->EmbedControl(newControl));
        CFRelease (cfstr);
    }

	DisposeHandle (h1);
#endif
}
コード例 #4
0
ファイル: shellscroll.c プロジェクト: dvincent/frontier
pascal void ScrollThumbActionProc (void) {

	SInt32 theValue;
    hdlscrollbar hscrollbar;
    Point thePoint;
    Rect theRect;
    long ctscroll;
	tydirection dir;
	long currvalue;
	hdlwindowinfo h = shellwindowinfo;
	short baselineoffset;

    if (h == nil) /*defensive driving*/
    	return;

	hscrollbar = (**h).vertscrollbar;
	
	if (!flverticalscroll)
		hscrollbar = (**h).horizscrollbar;
	
	zerorect (&theRect);
	
	GetBestControlRect (hscrollbar, &theRect, &baselineoffset);
 	//theRect = (**hscrollbar).contrlRect;
 	
 	if (flverticalscroll)
		
		insetrect (&theRect, -kThumbTrackLengthSlop, -kThumbTrackWidthSlop);
		
 	else
		
		insetrect (&theRect, -kThumbTrackWidthSlop, -kThumbTrackLengthSlop);
	
    GetMouse (&thePoint);
        
    if (pointinrect (thePoint, theRect))
		
		theValue = CalcValueFromPoint (hscrollbar, thePoint);
		
	else
		
		theValue = gStartValue;
		
	currvalue = (**h).vertscrollinfo.cur;
	
	if (theValue != GetControlValue (hscrollbar)) {	// if we scrolled
		
		EnableDrawing ();

		ctscroll = theValue - GetControlValue (hscrollbar);
		
		dir = scrolldirection (flverticalscroll, ctscroll > 0);	
		
	 	(*shellglobals.scrollroutine) (dir, false, abs (ctscroll));
	 	
		(**h).vertscrollinfo.cur = theValue;

		DisableDrawing ();
		} /*if*/
	
	return;
	} /*ScrollThumbActionProc*/
コード例 #5
0
ファイル: shellscroll.c プロジェクト: dvincent/frontier
SInt32 CalcValueFromPoint (ControlHandle hControl, Point thePoint) {
	
	/*Figure where we are in scroll bar terms.*/

	SInt32 theValue = 0, theRange, theDistance, thePin;
	Rect rectControl, indicatorbounds;
	WindowPtr lpWindow;
	long thumbheight = 16;
	long thumbwidth = 16;
	RgnHandle indicatorregion = NewRgn ();
	long gTotalVSizeAdjust, gTotalWidthAdjust;
	short baselineoffset;
	
	GetControlRegion (hControl, kControlIndicatorPart, indicatorregion);
	GetRegionBounds (indicatorregion, &indicatorbounds);
	
	thumbheight = indicatorbounds.bottom - indicatorbounds.top;
	
	thumbwidth = indicatorbounds.right - indicatorbounds.left;
	
	DisposeRgn (indicatorregion);
	
	gTotalVSizeAdjust = ((kScrollArrowWidth * 2) + thumbheight);
	
	gTotalWidthAdjust = ((kScrollArrowWidth * 2) + thumbwidth);

	lpWindow = shellwindow; // (*hControl)->contrlOwner;
	
	zerorect (&rectControl);
	
	GetBestControlRect (hControl, &rectControl, &baselineoffset);
	
	//rectControl = (*hControl)->contrlRect;
	
	theRange = GetControlMaximum ( hControl ) - GetControlMinimum ( hControl );
	
	if (flverticalscroll) {
	
		// Scroll distance adjusted for scroll arrows and the thumb
		theDistance = rectControl.bottom - rectControl.top - gTotalVSizeAdjust;
		// Pin thePoint to the middle of the thumb
		thePin = rectControl.top + (thumbheight / 2);
		thePin = lastpoint;
		theValue = ((thePoint.v - thePin) * theRange) / theDistance;
		} /*if*/
	
	else { /*horizontal scrolling*/
		
		theDistance = rectControl.right - rectControl.left - gTotalWidthAdjust;

		thePin = rectControl.left + (thumbwidth / 2);
		
		thePin = lastpoint;
		
		theValue = ((thePoint.h - thePin) * theRange) / theDistance;
		} /*else*/

	theValue += gValueSlop;
	
	if ( theValue < GetControlMinimum ( hControl ) )
		theValue = GetControlMinimum ( hControl );
	else if ( theValue > GetControlMaximum ( hControl ) )
		theValue = GetControlMaximum ( hControl );

	return theValue;
	} /*CalcValueFromPoint*/
コード例 #6
0
int FileDialog::ShowModal()
{
   OSErr err;
   NavDialogCreationOptions dialogCreateOptions;
   // set default options
   ::NavGetDefaultDialogCreationOptions(&dialogCreateOptions);
   
   // this was always unset in the old code
   dialogCreateOptions.optionFlags &= ~kNavSelectDefaultLocation;
   
   wxMacCFStringHolder message(m_message, GetFont().GetEncoding());
   dialogCreateOptions.windowTitle = message;
   
   wxMacCFStringHolder defaultFileName(m_fileName, GetFont().GetEncoding());
   dialogCreateOptions.saveFileName = defaultFileName;
   
   NavDialogRef dialog;
   NavObjectFilterUPP navFilterUPP = NULL;
   CustomData myData;
   
   SetRect(&myData.bounds, 0, 0, 0, 0);
   myData.me = this;
   myData.window = NULL;
   myData.defaultLocation = m_dir;
   myData.userpane = NULL;
   myData.choice = NULL;
   myData.button = NULL;
   myData.saveMode = false;
   myData.showing = true;
   
   Rect r;
   SInt16 base;
   SInt16 margin = 3;
   SInt16 gap = 0;
   
   MakeUserDataRec(&myData , m_wildCard);
   myData.currentfilter = m_filterIndex;
   size_t numFilters = myData.extensions.GetCount();
   if (numFilters)
   {
      CreateNewMenu(0, 0, &myData.menu);
      
      for ( size_t i = 0 ; i < numFilters ; ++i )
      {
         ::AppendMenuItemTextWithCFString(myData.menu,
                                          wxMacCFStringHolder(myData.name[i],
                                                              GetFont().GetEncoding()),
                                          4,
                                          i,
                                          NULL);
      }
      
      SetRect(&r, 0, margin, 0, 0);
      CreatePopupButtonControl(NULL, &r, CFSTR("Format:"), -12345, true, -1, teJustLeft, normal, &myData.choice);
      SetControlID(myData.choice, &kChoiceID);
      SetControlPopupMenuRef(myData.choice, myData.menu);
      SetControl32BitMinimum(myData.choice, 1);
      SetControl32BitMaximum(myData.choice, myData.name.GetCount());
      SetControl32BitValue(myData.choice, myData.currentfilter + 1);
      GetBestControlRect(myData.choice, &r, &base);
      SizeControl(myData.choice, r.right - r.left, r.bottom - r.top);
      UnionRect(&myData.bounds, &r, &myData.bounds);
      gap = 15;

      HIObjectSetAuxiliaryAccessibilityAttribute((HIObjectRef)myData.choice, 0, kAXDescriptionAttribute, CFSTR("Format"));
   }
   
   if (!m_buttonlabel.IsEmpty())
   {
      wxMacCFStringHolder cfString(wxStripMenuCodes(m_buttonlabel).c_str(), wxFONTENCODING_DEFAULT);
      SetRect(&r, myData.bounds.right + gap, margin, 0, 0);
      CreatePushButtonControl(NULL, &r, cfString, &myData.button);
      SetControlID(myData.button, &kButtonID);
      GetBestControlRect(myData.button, &r, &base);
      SizeControl(myData.button, r.right - r.left, r.bottom - r.top);
      UnionRect(&myData.bounds, &r, &myData.bounds);
   }
   
   // Expand bounding rectangle to include a top and bottom margin
   myData.bounds.top -= margin;
   myData.bounds.bottom += margin;
   
   dialogCreateOptions.optionFlags |= kNavNoTypePopup;
   
   if (m_dialogStyle & wxFD_SAVE)
   {
      dialogCreateOptions.modality = kWindowModalityWindowModal;
      dialogCreateOptions.parentWindow = (WindowRef) GetParent()->MacGetTopLevelWindowRef();
   
      myData.saveMode = true;
      
      if (!numFilters)
      {
         dialogCreateOptions.optionFlags |= kNavNoTypePopup;
      }
      dialogCreateOptions.optionFlags |= kNavDontAutoTranslate;
      dialogCreateOptions.optionFlags |= kNavDontAddTranslateItems;
      
      // The extension is important
      if (numFilters < 2)
         dialogCreateOptions.optionFlags |= kNavPreserveSaveFileExtension;
      
#if TARGET_API_MAC_OSX
      if (!(m_dialogStyle & wxFD_OVERWRITE_PROMPT))
      {
         dialogCreateOptions.optionFlags |= kNavDontConfirmReplacement;
      }
#endif
      
      err = ::NavCreatePutFileDialog(&dialogCreateOptions,
                                     // Suppresses the 'Default' (top) menu item
                                     kNavGenericSignature, kNavGenericSignature,
                                     sStandardNavEventFilter,
                                     &myData, // for defaultLocation
                                     &dialog);
   }
   else
   {
      
      //let people select bundles/programs in dialogs
      dialogCreateOptions.optionFlags |= kNavSupportPackages;
      
      navFilterUPP = NewNavObjectFilterUPP(CrossPlatformFilterCallback);
      err = ::NavCreateGetFileDialog(&dialogCreateOptions,
                                     NULL, // NavTypeListHandle
                                     sStandardNavEventFilter,
                                     NULL, // NavPreviewUPP
                                     navFilterUPP,
                                     (void *) &myData, // inClientData
                                     &dialog);
   }
   
   if (err == noErr)
      err = ::NavDialogRun(dialog);
   
   if (err == noErr)
   {
      myData.window = NavDialogGetWindow(dialog);
      Rect r;

      // This creates our "fake" dialog with the same dimensions as the sheet so
      // that Options dialogs will center properly on the sheet.  The "fake" dialog
      // is never actually seen.
      GetWindowBounds(myData.window, kWindowStructureRgn, &r);
      wxDialog::Create(NULL,  // no parent...otherwise strange things happen
                       wxID_ANY,
                       wxEmptyString,
                       wxPoint(r.left, r.top),
                       wxSize(r.right - r.left, r.bottom - r.top));
      
      BeginAppModalStateForWindow(myData.window);
      
      while (myData.showing)
      {
         wxTheApp->MacDoOneEvent();
      }
      
      EndAppModalStateForWindow(myData.window);
   }
   
   // clean up filter related data, etc.
   if (navFilterUPP)
      ::DisposeNavObjectFilterUPP(navFilterUPP);
   
   if (err != noErr)
      return wxID_CANCEL;
   
   NavReplyRecord navReply;
   err = ::NavDialogGetReply(dialog, &navReply);
   if (err == noErr && navReply.validRecord)
   {
      AEKeyword   theKeyword;
      DescType    actualType;
      Size        actualSize;
      FSRef       theFSRef;
      wxString thePath ;
      
      m_filterIndex = myData.currentfilter;
      
      long count;
      ::AECountItems(&navReply.selection , &count);
      for (long i = 1; i <= count; ++i)
      {
         err = ::AEGetNthPtr(&(navReply.selection), i, typeFSRef, &theKeyword, &actualType,
                             &theFSRef, sizeof(theFSRef), &actualSize);
         if (err != noErr)
            break;
         
         if (m_dialogStyle & wxFD_SAVE)
            thePath = wxMacFSRefToPath( &theFSRef , navReply.saveFileName ) ;
         else
            thePath = wxMacFSRefToPath( &theFSRef ) ;
         
         if (!thePath)
         {
            ::NavDisposeReply(&navReply);
            return wxID_CANCEL;
         }
         
         m_path = ConvertSlashInFileName(thePath);
         m_paths.Add(m_path);
         m_fileName = wxFileNameFromPath(m_path);
         m_fileNames.Add(m_fileName);
      }
      // set these to the first hit
      m_path = m_paths[0];
      m_fileName = wxFileNameFromPath(m_path);
      m_dir = wxPathOnly(m_path);
   }
   ::NavDisposeReply(&navReply);
   
   return (err == noErr) ? wxID_OK : wxID_CANCEL;
}