// ---------------------------------------------------------------------------
// 
// -----------
void bToolPrintArea::set_as_geo(WindowRef wd){
ControlRef	c;
ControlID	cid={kPrintAreaSignature,0};
i2dvertex	ivxa={_vxr.left,_vxr.top};
i2dvertex	ivxb={_vxr.right,_vxr.bottom};
d2dvertex	dvxa,dvxb;
char		val[256];

	Convert(&dvxa,&ivxa);
	Convert(&dvxb,&ivxb);

	cid.id=kPrintAreaWID;
	GetControlByID(wd,&cid,&c);
	sprintf(val,"%.*f",_gapp->document()->dist_pref_digits(),dvxb.x-dvxa.x);
	SetTextControlValue(c,val);

	cid.id=kPrintAreaHID;
	GetControlByID(wd,&cid,&c);
	sprintf(val,"%.*f",_gapp->document()->dist_pref_digits(),dvxa.y-dvxb.y);
	SetTextControlValue(c,val);

bGenericUnit*		u=_gapp->distMgr()->get();
	u->short_name(val);
	for(int i=kPrintAreaWUnitID;i<=kPrintAreaHUnitID;i++){
		cid.id=i;
		GetControlByID(wd,&cid,&c);
		SetTextControlValue(c,val);
	}
}
// ---------------------------------------------------------------------------
// 
// -----------
void bToolPrintArea::set_as_pix(WindowRef wd){
ControlRef	c;
ControlID	cid={kPrintAreaSignature,0};
i2dvertex	ivxa={_vxr.left,_vxr.top};
i2dvertex	ivxb={_vxr.right,_vxr.bottom};
CGPoint		pa,pb;
char		val[256];

	Convert(&pa,&ivxa);
	Convert(&pb,&ivxb);

	cid.id=kPrintAreaWID;
	GetControlByID(wd,&cid,&c);
	sprintf(val,"%.0f",round(pb.x-pa.x));
	SetTextControlValue(c,val);

	cid.id=kPrintAreaHID;
	GetControlByID(wd,&cid,&c);
	sprintf(val,"%.0f",round(pa.y-pb.y));
	SetTextControlValue(c,val);

	for(int i=kPrintAreaWUnitID;i<=kPrintAreaHUnitID;i++){
		cid.id=i;
		GetControlByID(wd,&cid,&c);
		SetTextControlValue(c,kUnitPixel);
	}
}
// ---------------------------------------------------------------------------
// 
// -----------
bool bToolShape::edit_event(EventRef evt, WindowRef wd){
bool		b=true;
HICommand	cmd;
ControlRef	c;
ControlID	cid={kShapeEditSign,kShapeCenterID};

	if(GetEventClass(evt)==kEventClassCommand){
		GetEventParameter(evt,kEventParamDirectObject,typeHICommand,NULL,sizeof(HICommand),NULL,&cmd);
		switch(cmd.commandID){
			case kHICommandOK:
				GetControlByID(wd,&cid,&c);
				_ctr=GetControl32BitValue(c);
				cid.id=kShapeOpenFicheID;
				GetControlByID(wd,&cid,&c);
				_opn=GetControl32BitValue(c);
				cid.id=kShapeCMMeasID;
				GetControlByID(wd,&cid,&c);
				_cm=GetControl32BitValue(c);
				break;
			case kHICommandCancel:
				break;
			default:
				b=false;
				break;
		}
	}
	return(b);
}
Example #4
0
OSStatus
GetURLToRegister(char * url, char * neighborhood)
{
    ControlID 		controlID1 = { kNSLSample, kAddressEditText };
    ControlID 		controlID2 = { kNSLSample, kNeighborhoodEditText };
    ControlRef		control;
    Size		actualSize;
    OSStatus		err;
    
    err = GetControlByID(gRegisterWindow, &controlID1, &control);
    if (err == noErr)
    {
        // Get the address the user typed into the Register sheet.
        err = GetControlData(control, 0, kControlEditTextTextTag, kMaxStringLength, url, &actualSize);
        if (err == noErr)
        {
            url[actualSize] = '\0';
            
            // Get the neighborhood the user typed into the Register sheet.
            err = GetControlByID(gRegisterWindow, &controlID2, &control);
            if (err == noErr)
            {
                err = GetControlData(control, 0, kControlEditTextTextTag, kMaxStringLength, neighborhood, &actualSize);
                if (err == noErr) neighborhood[actualSize] = '\0';
            }
        }
    }
    
    return err;
}
// ---------------------------------------------------------------------------
// 
// -----------
void bToolPrintArea::set_as_ppsz(WindowRef wd){
ControlRef	c;
ControlID	cid={kPrintAreaSignature,0};
i2dvertex	ivxa={_vxr.left,_vxr.bottom};
i2dvertex	ivxb={_vxr.right,_vxr.top};
CGPoint		pa,pb;
char		val[256];
float		m;

	Convert(&pa,&ivxa);
	Convert(&pb,&ivxb);

	cid.id=kPrintAreaWID;
	GetControlByID(wd,&cid,&c);
	m=pb.x-pa.x;
	m*=(2.54/72.0);
	sprintf(val,"%.2f",m);
	SetTextControlValue(c,val);

	cid.id=kPrintAreaHID;
	GetControlByID(wd,&cid,&c);
	m=pb.y-pa.y;
	m*=(2.54/72.0);
	sprintf(val,"%.2f",m);
	SetTextControlValue(c,val);

	message_string(kMsgCentimetersAB,val,0);
	for(int i=kPrintAreaWUnitID;i<=kPrintAreaHUnitID;i++){
		cid.id=i;
		GetControlByID(wd,&cid,&c);
		SetTextControlValue(c,val);
	}
}
void MakeWindow(IBNibRef 	nibRef)
{
    WindowRef	window;
    OSStatus		err;
    EventHandlerRef	ref;
    EventTypeSpec	winEvents[] = { { kEventClassCommand, kEventCommandProcess },
                                                { kEventClassWindow, kEventWindowClose },
                                                { kEventClassWindow, kEventWindowDrawContent },
                                                { kEventClassWindow, kEventWindowBoundsChanged }, 
                                                { kEventClassMovieExtractState, kEventKQueue } };

    err = CreateWindowFromNib(nibRef, CFSTR("Window"), &window);
    mWindow = window;

    mWinEventHandler = NewEventHandlerUPP(WindowEventHandler);
    err = InstallWindowEventHandler(window, mWinEventHandler, GetEventTypeCount( winEvents ), winEvents, 0, &ref);

    ControlRef control;

    err = GetControlByID( window, &kPlayBtnID, &control );
    mButtonRef = control;

    err = GetControlByID( window, &kMovNameTxtID, &control );
    mMovNameRef = control;

    ShowWindow(window);
}
Example #7
0
bool enablePlayerButtons(bool bPlay, bool bPause, bool bStop, bool bInfo)
{
    ControlRef cPlay, cPause, cStop, cInfo;
    ControlID cID;
    OSStatus iErr;

    /* Get control references.. */
    
    cID.signature = FOUR_CHAR_CODE('play');
    cID.id = 1;
    if (noErr != (iErr = GetControlByID(g_refPlayerWin, &cID, &cPlay)))
    {
        fprintf(stderr, "enableButtons() - GetControlByID(play) failed, returning %lu!\n", (unsigned long) iErr);
        return false;
    }

    cID.signature = FOUR_CHAR_CODE('paus');
    cID.id = 2;
    if (noErr != (iErr = GetControlByID(g_refPlayerWin, &cID, &cPause)))
    {
        fprintf(stderr, "enableButtons() - GetControlByID(paus) failed, returning %lu!\n", (unsigned long) iErr);
        return false;
    }

    cID.signature = FOUR_CHAR_CODE('stop');
    cID.id = 3;
    if (noErr != (iErr = GetControlByID(g_refPlayerWin, &cID, &cStop)))
    {
        fprintf(stderr, "enableButtons() - GetControlByID(stop) failed, returning %lu!\n", (unsigned long) iErr);
        return false;
    }

    cID.signature = FOUR_CHAR_CODE('info');
    cID.id = 4;
    if (noErr != (iErr = GetControlByID(g_refPlayerWin, &cID, &cInfo)))
    {
        fprintf(stderr, "enableButtons() - GetControlByID(info) failed, returning %lu!\n", (unsigned long) iErr);
        return false;
    }

    /* And set everything en masse. */

    if (bPlay)  {  EnableControl(cPlay);   }
    else        {  DisableControl(cPlay);  }

    if (bPause)  {  EnableControl(cPause);   }
    else         {  DisableControl(cPause);  }

    if (bStop)  {  EnableControl(cStop);   }
    else        {  DisableControl(cStop);  }

    if (bInfo)  {  EnableControl(cInfo);   }
    else        {  DisableControl(cInfo);  }

    return true;
}
OSStatus
WindowRegisterTXNScrollProcs( WindowRef window, TXNObject txnObj )
{
    OSStatus status = memFullErr;
    ControlRef aScrollControl;
    ControlRef* pScrollControl;
    ControlID controlID = { kMyVerticalScrollBar, 0 };
    
    // allocate memory to hold scroll controls
    Ptr scrollControlArray = NewPtr( sizeof(ControlRef) * 2 ); // don't forget to dispose when finished
    require( scrollControlArray != NULL, MemoryError );
    
    // pointer to first ControlRef in array
    pScrollControl = (ControlRef*)scrollControlArray;
    
    // set up and store vertical scroll control
    status = GetControlByID( window, &controlID, &aScrollControl );
    require_noerr( status, CantSetupControl );
    status = ControlRegisterActionProc( window, aScrollControl, kTXNVertical );
    require_noerr( status, CantSetupControl );
                            
    *pScrollControl = aScrollControl;
    
    // advance to next ControlRef in array
    pScrollControl++;
    
    // set up and store horizontal scroll control
    controlID.signature = kMyHorizontalScrollBar;
    status = GetControlByID( window, &controlID, &aScrollControl);
    require_noerr( status, CantSetupControl );
    status = ControlRegisterActionProc( window, aScrollControl, kTXNHorizontal );
    require_noerr( status, CantSetupControl );
    *pScrollControl = aScrollControl;
    
    // The scroll info proc is MLTE's way to tell you that the content of
    // the TXNObject has changed and that the scrollbars should be updated
    // We need a way to find the controlRefs to our scroll controls while inside the callback.
    // One way to do that is just put a pointer to an array of controlRefs inside the userData
    // item for the callback.  (You could also put a pointer to your own struct/class instance)
    if( scrollControlArray != NULL )
    {
        gScrollInfoUPP = NewTXNScrollInfoUPP( MyMLTEScrollInfoCallback );
        require( gScrollInfoUPP != NULL, CantMakeScrollUPP );
        TXNRegisterScrollInfoProc( txnObj, gScrollInfoUPP, (SInt32)scrollControlArray/*userData*/);
    }
    
    MemoryError:
    return status;
    
    // clean up allocated memory if jumped to here
    CantSetupControl:
    CantMakeScrollUPP:
    DisposePtr( scrollControlArray );
    return status;
    
}
// ---------------------------------------------------------------------------
// 
// -----------
void bToolPrintArea::pop_kind_action(WindowRef wd){
ControlRef	c;
ControlID	cid={kPrintAreaSignature,0};
int			k;

	put_area(wd);

	cid.id=kPrintAreaPopKindID;
	GetControlByID(wd,&cid,&c);
	k=GetControl32BitValue(c);
	switch(k){
		case kPrintAreaPopKindMenuGeo:
			set_as_geo(wd);
			cid.id=kPrintAreaFrameCustomSizeID;
			GetControlByID(wd,&cid,&c);
			ShowControl(c);
			cid.id=kPrintAreaFrameStandardSizeID;
			GetControlByID(wd,&cid,&c);
			HideControl(c);
			break;
		case kPrintAreaPopKindMenuPix:
			set_as_pix(wd);
			cid.id=kPrintAreaFrameCustomSizeID;
			GetControlByID(wd,&cid,&c);
			ShowControl(c);
			cid.id=kPrintAreaFrameStandardSizeID;
			GetControlByID(wd,&cid,&c);
			HideControl(c);
			break;
		case kPrintAreaPopKindMenuCustom:
			set_as_ppsz(wd);
			cid.id=kPrintAreaFrameCustomSizeID;
			GetControlByID(wd,&cid,&c);
			ShowControl(c);
			cid.id=kPrintAreaFrameStandardSizeID;
			GetControlByID(wd,&cid,&c);
			HideControl(c);
			break;
		case kPrintAreaPopKindMenuStandard:
			cid.id=kPrintAreaFrameCustomSizeID;
			GetControlByID(wd,&cid,&c);
			HideControl(c);
			cid.id=kPrintAreaFrameStandardSizeID;
			GetControlByID(wd,&cid,&c);
			ShowControl(c);
			
			cid.id=kPrintAreaPopSizeID;
			GetControlByID(wd,&cid,&c);
			SetControl32BitValue(c,_pprkind);
			break;
	}
	_sizekind=k;
}
Example #10
0
// ---------------------------------------------------------------------------
// 
// -----------
void bToolShape::edit_init(WindowRef wd){
ControlRef	c;
ControlID	cid={kShapeEditSign,kShapeCenterID};

	GetControlByID(wd,&cid,&c);
	SetControl32BitValue(c,_ctr);
	cid.id=kShapeOpenFicheID;
	GetControlByID(wd,&cid,&c);
	SetControl32BitValue(c,_opn);
	cid.id=kShapeCMMeasID;
	GetControlByID(wd,&cid,&c);
	SetControl32BitValue(c,_cm);
}
Example #11
0
XControl::XControl(XWindow *window, OSType signature, UInt32 id)
    :mListener(0)
{
    ControlID cid = { signature, id };
    RequireNoErrString(GetControlByID(window->MacWindow(), &cid, &mControl), "GetControlByID failed");
    SetControlReference(mControl, SInt32(this));
}
Example #12
0
ControlRef GetControl(int id)
{
	ControlRef cref;
	ControlID cid={0,id};
	GetControlByID(win,&cid,&cref);
	return cref;
}
Example #13
0
bool unloadInfoWin()
{
    DataBrowserCallbacks dbc;
    ControlRef cRef;
    ControlID cID;

    cID.signature = FOUR_CHAR_CODE('tags');
    cID.id = 16;
    if (noErr == GetControlByID(g_refInfoWin, &cID, &cRef))
    {
        dbc.version = kDataBrowserLatestCallbacks;
        if (noErr == InitDataBrowserCallbacks(&dbc))
        {
            SetDataBrowserCallbacks(cRef, &dbc);
        }
    }

    clearInfoWin();

    HideWindow(g_refInfoWin);
    RemoveEventHandler(g_refInfoHdlr);
    DisposeWindow(g_refInfoWin);
    DisposeEventHandlerUPP(g_lpfnInfoProc);
    DisposeDataBrowserItemDataUPP(g_lpfnGSIDProc);

    /* Clean up any previous contents */
    
    return true;
}
Example #14
0
void
GetServiceTypeToLookup(CFMutableStringRef * serviceString, UInt16 * serviceMenuItem)
{
    ControlID 		controlID = { kNSLSample, kServicesTypePopup };
    ControlRef		control;
    CFStringRef		outString;
    MenuRef		menu;
    SInt16		value;
    OSStatus		err;
    
    err = GetControlByID(gMainWindow, &controlID, &control);
    if (err == noErr)
    {
        value = GetControlValue(control);
        if (serviceString)
        {
            menu = GetControlPopupMenuHandle(control);
            if (menu)
            {
                CopyMenuItemTextAsCFString(menu, value, &outString);
                if (serviceString)
                {
                    *serviceString = CFStringCreateMutableCopy(NULL, CFStringGetLength(outString), outString);
                    CFStringLowercase(*serviceString, NULL);
                }
                if (outString) CFRelease(outString);
            }
        }
        
        if (serviceMenuItem) *serviceMenuItem = value;
    }
}
void PreferencesDialog::initDialog()
{
	ControlHandle popupButtonControl;
	ControlID popupButtonControlID = {kAppSignature, 130};
	MenuRef menu;
	
	GetControlByID(preferencesWindow, &popupButtonControlID, &popupButtonControl);
	GetControlData(popupButtonControl, kControlEntireControl, kControlPopupButtonMenuRefTag, sizeof(menu), &menu, NULL);

	unsigned int nPorts = midiin ? midiin->getPortCount() : 0;

	if (nPorts)
	{
		UInt32 numItems = CountMenuItems(menu);
		DeleteMenuItems(menu, 1, numItems); 
		
		// Check inputs.
		std::string portName;
		unsigned int nSelectedDevice = 0;
		for (unsigned int i = 0; i < nPorts; i++ ) 
		{
			try 
			{
				portName = midiin->getPortName(i);
			}
			catch (RtMidiError &error) 
			{
				error.printMessage();
			}
			
			if (strcmp(portName.c_str(), m_dataBase->restore(KEY_MIDIDEVICE)->getStringValue()) == 0)
				nSelectedDevice = i;
			
			CFStringRef CFStrPortName = CFStringCreateWithCString(NULL, portName.c_str(), kCFStringEncodingASCII);
			AppendMenuItemTextWithCFString(menu, CFStrPortName, 0, kMIDIDeviceBaseCommand + i, 0);
			CFRelease(CFStrPortName);
			
		}

		/*AppendMenuItemTextWithCFString(menu, CFSTR("Temp1"), 0, kMIDIDeviceBaseCommand + 1, 0);
		AppendMenuItemTextWithCFString(menu, CFSTR("Temp2"), 0, kMIDIDeviceBaseCommand + 2, 0);
		nPorts+=2;*/
		
		SetControlMaximum(popupButtonControl, nPorts);
		
		SetControlValue(popupButtonControl, nSelectedDevice + 1);
		
		storeMidiDeviceName(nSelectedDevice);

		EnableControl(popupButtonControl);			
	}
	else
	{
		DisableControl(popupButtonControl);	
	}
	
	updateControls();

	updateSliderVelocityAmplify();	
}
Example #16
0
void
TabbedWindow::DisableAllPanes( void )
{
    OSStatus status;
    ControlRef controlRef;
    ControlID controlID;
    
    controlID.signature = kTabPaneSignature;
    
    // loop through and disable all of the panes
    for ( int i = 1; i <= kTabPaneCount; i++ )
    {
        controlID.id = gPaneArray[i];
        status = GetControlByID( fWindowRef, &controlID, &controlRef );
        check_noerr( status );
        
        // disable the panes
        if ( status == noErr )
        {
            SetControlVisibility( controlRef, false, false );
            DisableControl( controlRef );
        }
    }
    return;
}
Example #17
0
// --------------------------------------------------------------------------------------
void SetPrefsWindowHelpTags(WindowRef prefsWindow)
{
	CFBundleRef mainBundle;
	CFStringRef dataBrowserString, userPaneString, staticTextString;
	HMHelpContentRec dataBrowserContent, userPaneContent, staticTextContent;
	ControlID dataBrowserID = {kAppSignature, kIconDataBrowserID};
	ControlRef dataBrowser, rootControl, userPane, staticText;
	UInt16 panelIndex;
	
	mainBundle = CFBundleGetMainBundle();
	
		// set the help tag for the data browser
	dataBrowserString = CFCopyLocalizedStringFromTableInBundle(CFSTR("Window Data Browser"), 
																NULL, mainBundle, NULL);
	
	dataBrowserContent.version = kMacHelpVersion;
	SetRect(&dataBrowserContent.absHotRect, 0, 0, 0, 0);
	dataBrowserContent.tagSide = kHMDefaultSide;
	dataBrowserContent.content[kHMMinimumContentIndex].contentType = kHMCFStringContent;
	dataBrowserContent.content[kHMMinimumContentIndex].u.tagCFString = dataBrowserString;
	dataBrowserContent.content[kHMMaximumContentIndex].contentType = kHMNoContent;
	
	GetControlByID(prefsWindow, &dataBrowserID, &dataBrowser);
	HMSetControlHelpContent(dataBrowser, &dataBrowserContent);
	CFRelease(dataBrowserString);
	
		// set the help tags for the user panes
	userPaneString = CFCopyLocalizedStringFromTableInBundle(CFSTR("User Pane"), NULL, 
															mainBundle, NULL);
	
	userPaneContent.version = kMacHelpVersion;
	SetRect(&userPaneContent.absHotRect, 0, 0, 0, 0);
	userPaneContent.tagSide = kHMDefaultSide;
	userPaneContent.content[kHMMinimumContentIndex].contentType = kHMCFStringContent;
	userPaneContent.content[kHMMinimumContentIndex].u.tagCFString = userPaneString;
	userPaneContent.content[kHMMaximumContentIndex].contentType = kHMNoContent;
	
		// set the help tags for the static texts
	staticTextString = CFCopyLocalizedStringFromTableInBundle(CFSTR("Static Text"), NULL, 
																mainBundle, NULL);
	
	staticTextContent.version = kMacHelpVersion;
	SetRect(&staticTextContent.absHotRect, 0, 0, 0, 0);
	staticTextContent.tagSide = kHMDefaultSide;
	staticTextContent.content[kHMMinimumContentIndex].contentType = kHMCFStringContent;
	staticTextContent.content[kHMMinimumContentIndex].u.tagCFString = staticTextString;
	staticTextContent.content[kHMMaximumContentIndex].contentType = kHMNoContent;
	
	GetRootControl(prefsWindow, &rootControl);
	for (panelIndex = 1; panelIndex <=  kNumberOfRows; panelIndex++)
	{
		GetIndexedSubControl(rootControl, panelIndex, &userPane);
		HMSetControlHelpContent(userPane, &userPaneContent);
		
		GetIndexedSubControl(userPane, 1, &staticText);
		HMSetControlHelpContent(staticText, &staticTextContent);
	}
	CFRelease(userPaneString);
	CFRelease(staticTextString);
}
// ---------------------------------------------------------------------------
// 
// -----------
void bToolJustification::edit_init(WindowRef wd){
ControlRef	c;
ControlID	cid={kJustificationEditSign,kJustificationButtonsID};
		
	GetControlByID(wd,&cid,&c);
	SetControl32BitValue(c,_jmd);
}
Example #19
0
bool unloadPlayerWin()
{
    ControlRef cRef;
    ControlID cID;
    OSStatus iErr;

    cID.signature = FOUR_CHAR_CODE('volu');
    cID.id = 6;
    if (noErr != (iErr = GetControlByID(g_refPlayerWin, &cID, &cRef)))
    {
        /* We don't return false here since this is always called on the way out. */
        fprintf(stderr, "unloadPlayerWin() - GetControlByID() failed, returning %lu!\n", (unsigned long) iErr);
    }
    else
    {
        SetControlAction(cRef, (ControlActionUPP) -1);        
    }
    
    HideWindow(g_refPlayerWin);
    RemoveEventHandler(g_refSeekHdlr);
    RemoveEventHandler(g_refPlayerHdlr);
    DisposeWindow(g_refPlayerWin);
    DisposeEventHandlerUPP(g_lpfnPlayerProc);
    DisposeControlActionUPP(g_lpfnVolumeProc);

    return true;
}
// ---------------------------------------------------------------------------
// 
// -----------
void bToolPrintArea::puts(WindowRef wd){
ControlRef	c;
ControlID	cid={kPrintAreaSignature,0};

	put_area(wd);
	cid.id=kPrintAreaDrawAreaID;
	GetControlByID(wd,&cid,&c);
bool	vis=GetControl32BitValue(c);
	if(vis!=_draw){
		clearTempPathContext(true);
		_draw=vis;
		_gapp->printMgr()->set_print_area(&_vxr);
		update(true);
		validTempPathContext();
	}
	else if(_draw){
		clearTempPathContext(true);
		_gapp->printMgr()->set_print_area(&_vxr);
		update(true);
		validTempPathContext();
	}
	else{
		_gapp->printMgr()->set_print_area(&_vxr);
	}
}
Example #21
0
bool CARBON_GUI::init_controls() {
	int i;
	for(i=0;i<MAIN_CONTROLS_NUM;i++) {
		err = GetControlByID(window,&mainControlsID[i],&mainControls[i]);
		if(err != noErr) {
		//	printf("%d - %d - %d \n",i,mainControlsID[i].id,err);
			msg->error("Can't get control for button %d (%d)",i,err);
		}
	}
	
	/* By default start with live output enabled */
	jmix->set_lineout(true);
	SetControlValue(mainControls[SNDOUT_BUT],1);

	/* install main event handler+ */
	err = InstallWindowEventHandler (window, 
            NewEventHandlerUPP (MainWindowEventHandler), 
            GetEventTypeCount(events), events, 
            this, NULL);
	if(err != noErr) msg->error("Can't install main eventHandler");
	
	/* install main command handler */
    err = InstallWindowEventHandler (window, 
            NewEventHandlerUPP (MainWindowCommandHandler), 
            GetEventTypeCount(commands), commands, 
            this, NULL);
	if(err != noErr) msg->error("Can't install main commandHandler");
}
Example #22
0
bool setPlayerWinBarMode(bool bIndef)
{
    ControlRef cRef;
    ControlID cID;
    OSStatus iErr;
    Boolean bData;

    cID.signature = FOUR_CHAR_CODE('fpos');
    cID.id = 7;
    if (noErr != (iErr = GetControlByID(g_refPlayerWin, &cID, &cRef)))
    {
        fprintf(stderr, "setPlayerWinBarMode() - GetControlByID() failed, returning %lu!\n", (unsigned long) iErr);
        return false;
    }

    bData = bIndef;

    if (noErr != (iErr = SetControlData(cRef, kControlEntireControl, kControlProgressBarIndeterminateTag, sizeof(Boolean), &bData)))
    {
        fprintf(stderr, "setPlayerWinBarMode() - SetControlData() failed, returning %lu!\n", (unsigned long) iErr);
        return false;
    }

    return true;
}
Example #23
0
void palette_scenery_open(int x,int y)
{
	ControlID				ctrl_id;
	EventHandlerUPP			tab_event_upp;
	EventTypeSpec			tab_event_list[]={{kEventClassControl,kEventControlHit},
											  {kEventClassKeyboard,kEventRawKeyUp}};

		// open the window
		
	dialog_open(&palette_scenery_wind,"SceneryPalette");
	MoveWindow(palette_scenery_wind,x,y,FALSE);
	
		// setup the tabs
		
	dialog_set_tab(palette_scenery_wind,kSceneryTab,0,0,kSceneryTabCount);

	ctrl_id.signature=kSceneryTab;
	ctrl_id.id=0;
	GetControlByID(palette_scenery_wind,&ctrl_id,&palette_scenery_tab);
	
	tab_event_upp=NewEventHandlerUPP(palette_scenery_tab_proc);
	InstallControlEventHandler(palette_scenery_tab,tab_event_upp,GetEventTypeCount(tab_event_list),tab_event_list,palette_scenery_wind,NULL);

		// show palette
		
	ShowWindow(palette_scenery_wind);
}
Example #24
0
AUEditWindow::AUEditWindow(XController *owner, IBNibRef nibRef, CFStringRef name, AudioUnit editUnit, ComponentDescription inCompDesc ) :
	XWindow(owner, nibRef, name),
	mEditUnit(editUnit)
{
	Component editComp = FindNextComponent(NULL, &inCompDesc);
	
	verify_noerr(OpenAComponent(editComp, &mEditView));
	
	ControlRef rootControl;
	verify_noerr(GetRootControl(mWindow, &rootControl));

	ControlRef customControl = 0;

	ControlID controlID;
	controlID.signature    	= 'cust';
    controlID.id        	= 1000;
    GetControlByID( mWindow, &controlID, &customControl );

	ControlRef ourControl = customControl ? customControl : rootControl;

	Rect r = {0,0,400,400};
	ControlRef viewPane;
	if(customControl) GetControlBounds(ourControl, &r);

	Float32Point location = { r.left, r.top };
	Float32Point size = { Float32(r.right - r.left ), Float32(r.bottom - r.top ) };
	
	
	verify_noerr(AudioUnitCarbonViewCreate(mEditView, mEditUnit, mWindow, ourControl, &location, &size, &viewPane));

	GetControlBounds(viewPane, &r);
	size.x = r.right-r.left; size.y = r.bottom-r.top;
	if(!customControl) SetSize(size);
	Show();	
}
Example #25
0
OSStatus setProgress(int cur, int max)
{
	OSStatus err;
	ControlRef progressBar = NULL;
	ControlID id;

	id.signature = 'prog';
	id.id = 0;

	err = GetControlByID(gWindow, &id, &progressBar);
	if(err == noErr)
	{
		Boolean indeterminate;
		
		if(max == 0)
		{
			indeterminate = true;
			err = SetControlData(progressBar, kControlEntireControl, kControlProgressBarIndeterminateTag, sizeof(Boolean), (Ptr)&indeterminate);
		}
		else
		{
			double percentage = (double)cur / (double)max;
			SetControlMinimum(progressBar, 0);
			SetControlMaximum(progressBar, 100);
			SetControlValue(progressBar, (SInt16)(percentage * 100));

			indeterminate = false;
			err = SetControlData(progressBar, kControlEntireControl, kControlProgressBarIndeterminateTag, sizeof(Boolean), (Ptr)&indeterminate);

			Draw1Control(progressBar);
		}
	}

	return(err);
}
Example #26
0
TabbedWindow::TabbedWindow( void )
{
    OSStatus status;
    IBNibRef nibRef;
    fWindowRef = NULL;
    
    static const ControlID tabControlID = 
        { kMasterTabControlSignature, kMasterTabControlID };

    // Create a Nib reference passing the name of the nib file (without the .nib
    // extension) CreateNibReference only searches into the application bundle.
    status = CreateNibReference( CFSTR("main"), &nibRef );
    require_noerr( status, TabbedWindow_err );
	
    // Then create a window & set menubar based on Nib.
    status = CreateWindowFromNib( nibRef, CFSTR("MainWindow"), &fWindowRef );
    require_noerr( status, TabbedWindow_err );
    status = SetMenuBarFromNib( nibRef, CFSTR( "MenuBar" ) );
    require_noerr( status, TabbedWindow_err );

    // finsihed with the nib reference
    DisposeNibReference(nibRef);
    
    // what events will this window handle?
    status = this->RegisterWindowCarbonEventhandler();
    require_noerr( status, TabbedWindow_err );
    
    // start with current tab pane set to NULL.
    fCurrentTabPane = NULL;
    
    // start with all panes disabled
    this->DisableAllPanes();
    
    // Get a reference to the tab control in the window
    status = GetControlByID( fWindowRef, &tabControlID, &fTabControlRef );
    //check_noerr( status );
    
    // put event handlers on it
    status = InstallStandardEventHandler( GetControlEventTarget( fTabControlRef ) );
    check_noerr( status );
    
    // Switch to the tab content indicated by current value of the tab control
    if( status == noErr )
        status = this->SwitchTabPane( fTabControlRef );
    
    // show the new window
    ShowWindow( fWindowRef );
	
TabbedWindow_err:

    #if DEBUG_ERROR_LOGS
    if( status != noErr )
    {
        SysBeep(10);
        std::cout << "Error in TabbedWindow constructor:" << status << std::endl;
    }
    #endif

    return;
}
void PreferencesDialog::updateSliderVelocityAmplify()
{
	ControlHandle control, controlSlider;
	ControlID controlID1 = {kAppSignature, 127};
	ControlID controlID2 = {kAppSignature, 125};
	GetControlByID(preferencesWindow, &controlID1, &control);
	GetControlByID(preferencesWindow, &controlID2, &controlSlider);

	char buffer[1024];
	sprintf(buffer, "Record velocity (amplify: %i%%)", m_dataBase->restore(KEY_VELOCITYAMPLIFY)->getIntValue());
	
	CFStringRef CFStrVelocityAmplify = CFStringCreateWithCString(NULL, buffer, kCFStringEncodingASCII);
	SetControlTitleWithCFString(control, CFStrVelocityAmplify);
	CFRelease(CFStrVelocityAmplify);
	
	SetControlValue(controlSlider, m_dataBase->restore(KEY_VELOCITYAMPLIFY)->getIntValue());
}
UInt32 PreferencesDialog::getComboSelection()
{
	ControlHandle popupButtonControl;
	ControlID popupButtonControlID = {kAppSignature, 130};
	
	GetControlByID(preferencesWindow, &popupButtonControlID, &popupButtonControl);
	return (unsigned int)GetControlValue(popupButtonControl) - 1;
}
Example #29
0
void
AddServiceToPopupMenu(char * serviceType, UInt16 serviceLen, UInt16 * serviceMenuItem)
{
    ControlID 		controlID = { kNSLSample, kServicesTypePopup };
    ControlRef		control;
    CFStringRef		tempService = NULL;
    CFStringRef    	menuText = NULL;
    char		tempServiceString[kMaxTypeNameLength];
    CFComparisonResult	result = -1;
    MenuRef		menu;
    OSStatus		err = noErr;
    short		itemCount, i;
    
    if (serviceType)
    {
        err = GetControlByID(gMainWindow, &controlID, &control);
        if (err == noErr)
        {
            strncpy(tempServiceString, serviceType, serviceLen);
            tempServiceString[serviceLen] = '\0';
            
            for (i = 0; i < serviceLen; i++) tempServiceString[i] = toupper(tempServiceString[i]);
            
            tempService = CFStringCreateWithCString(NULL, tempServiceString, CFStringGetSystemEncoding());
            if (tempService)
            {
                menu = GetControlPopupMenuHandle(control);
                itemCount = CountMenuItems(menu);
                
                for (i = 1; i <= itemCount; i ++)
                {
                    CopyMenuItemTextAsCFString(menu, i , &menuText);
                    if (menuText)
                    {                        
                        result = CFStringCompare(menuText, tempService, kCFCompareCaseInsensitive);
                        if (result == kCFCompareEqualTo)
                        {
                            if (serviceMenuItem) *serviceMenuItem = i;
                            break;
                        }
                    }
                }
                
                if (result != kCFCompareEqualTo)
                {
                    err = AppendMenuItemTextWithCFString(menu, tempService, 0, 0, serviceMenuItem);
                    if (err == noErr)
                    {
                        SetControlMaximum(control, itemCount + 1);
                        if (serviceMenuItem) *serviceMenuItem = itemCount + 1;
                    }
                    CFRelease(tempService);
                }
            }
        }
    }
}
Example #30
0
OSStatus
TabbedWindow::GetControlFromWindow( WindowRef window, OSType sig, SInt32 id,
                                    ControlRef& gotControlRef )
{
    ControlID controlID;
    controlID.signature = sig;
    controlID.id = id;
    return GetControlByID( window, &controlID, &gotControlRef);
}