Esempio n. 1
0
string
Control::Generate_C_Code(void)
{

string result;

ostringstream   s;

switch(GetControlKind( ))
   {
   case ADaAn_FOR      :
         result= "for ( "+GetLoopCounter( );
         result+= " = "+GetForLowerBound( )->Generate_C_Code();
         result+= "; "+GetLoopCounter()+" <= "+GetForUpperBound()->Generate_C_Code();
         result+= "; ++" + GetLoopCounter() +")";
         break;
   case ADaAn_WHILE   :result = "while("+GetCondition( )->Generate_C_Code()+")"; break;
   case ADaAn_IF      :result = "if("+GetCondition( )->Generate_C_Code()+")"; break;
   case ADaAn_IF_ELSE   :result = "if/*then else*/("+GetCondition( )->Generate_C_Code()+")"; break;
   default: cerr<<endl<<"Fatal error, Control::Print_str(), unhandled operator ";
      throw(UNHANDLED_CASE);
      exit(EXIT_FAILURE);
   }
return result;

}
Esempio n. 2
0
void
Control::Substitute(map<string,string>* __mapping){
switch(GetControlKind()){
   case ADaAn_FOR      :
            if(__mapping->find(GetCounter()) != __mapping->end())
               SetCounterName(__mapping->operator[](GetCounter()));
            GetForLowerBound()->Substitute(__mapping);
            GetForUpperBound()->Substitute(__mapping);
            return;
   case ADaAn_WHILE   :
            if(__mapping->find(GetCounter()) != __mapping->end())
               SetCounterName(__mapping->operator[](GetCounter()));
            GetCondition()->Substitute(__mapping);
            return;
   case ADaAn_IF      :
            GetCondition()->Substitute(__mapping);
            return;
   case ADaAn_IF_ELSE   :
            GetCondition()->Substitute(__mapping);
            return;
   }

cerr<<"Control::Rename, Fatal error(unhandled operator)";
throw(UNHANDLED_CASE);
exit(EXIT_FAILURE);
}
Esempio n. 3
0
void OpenUserDataRec::EventProcCBEventMouseDown(NavCBRecPtr callBackParms)
{
    EventRecord *evt = callBackParms->eventData.eventDataParms.event;
    Point where = evt->where;
    QDGlobalToLocalPoint(GetWindowPort(callBackParms->window), &where);

    ControlRef whichControl = FindControlUnderMouse(where, callBackParms->window, NULL);
    if (whichControl != NULL)
    {
        ControlKind theKind;
        GetControlKind(whichControl, &theKind);

        // Moving the focus if we clicked in an focusable control
        if ((theKind.kind == kControlKindEditUnicodeText) ||
            (theKind.kind == kControlKindEditText) ||
            (theKind.kind == kControlKindDataBrowser) ||
            (theKind.kind == kControlKindListBox))
        {
            ControlRef currentlyFocusedControl;
            GetKeyboardFocus(callBackParms->window, &currentlyFocusedControl);
            if (currentlyFocusedControl != whichControl)
                SetKeyboardFocus(callBackParms->window, whichControl, kControlFocusNextPart);
        }
        HandleControlClick(whichControl, where, evt->modifiers, NULL);
    }
}
Esempio n. 4
0
void	AUCarbonViewControl::ControlToParameter()
{
#if !__LP64__
	if (mInControlInitialization)
		return;

	switch (mType) {
	case kTypeContinuous:
		{
			double controlValue = GetValueFract();
			Float32 paramValue = AUParameterValueFromLinear(controlValue, &mParam);
			mParam.SetValue(mListener, this, paramValue);
		}
		break;
	case kTypeDiscrete:
		{
			long value = GetValue();
			
			// special case [1] -- Menus
			if (mParam.HasNamedParams()) {
				// if we're dealing with menus they behave differently!
				// becaue setting min and max doesn't work correctly for the control value
				// first menu item always reports a control value of 1
				ControlKind ctrlKind;
				if (GetControlKind(mControl, &ctrlKind) == noErr) {
					if ((ctrlKind.kind == kControlKindPopupArrow) 
						|| (ctrlKind.kind == kControlKindPopupButton))				
					{
						value = value + long(mParam.ParamInfo().minValue) - 1;
					}
				}
			}
			
			// special case [2] -- Write-only boolean parameters
			AudioUnitParameterInfo AUPI = mParam.ParamInfo();
			
			bool isWriteOnlyBoolParameter = (	(AUPI.unit == kAudioUnitParameterUnit_Boolean) &&
												(AUPI.flags & kAudioUnitParameterFlag_IsWritable) &&
												!(AUPI.flags & kAudioUnitParameterFlag_IsReadable)	);
			if (isWriteOnlyBoolParameter) {
				value = 1;
			}
			
			mParam.SetValue (mListener, this, value);
		}
		break;
	case kTypeText:
		{
			Float32 val = mParam.GetValueFromString (GetTextValue());
			mParam.SetValue(mListener, this, (mParam.IsIndexedParam() ? (int)val : val));
			if (mParam.ValuesHaveStrings())
				ParameterToControl(val); //make sure we display the correct text (from the AU)
		}
		break;
	}
#endif
}
Esempio n. 5
0
string
Control::Print_str(int what_to_print)
{
string result;

ostringstream   s;
int   stmt1,stmt2;
GetEnclosedAssignments( &stmt1,&stmt2);
s<<"[ "<<stmt1<<", "<<stmt2<<" ]";
GetElsePartAssignments( &stmt1,&stmt2);
s<<"[ "<<stmt1<<", "<<stmt2<<" ]";

switch(GetControlKind( ))
   {
   case ADaAn_FOR      :result = "for("+GetLoopCounter( )+":"+GetForLowerBound( )->Print_str( )+":"+GetForUpperBound( )->Print_str( )+")"; break;
   case ADaAn_WHILE   :result = "while("+GetCondition( )->Print_str()+")"; break;
   case ADaAn_IF      :result = "if("+GetCondition( )->Print_str()+")"; break;
   case ADaAn_IF_ELSE   :result = "if the else("+GetCondition( )->Print_str()+")"; break;
   default: cerr<<endl<<"Fatal error, Control::Print_str(), unhandled operator ";
      throw(BAD_OPERATOR);
      exit(EXIT_FAILURE);
   }
result+="\tcounter = "+GetLoopCounter()+"\t"+s.str();
if(what_to_print == __SECURE_PRINT)
   return result;


result+="\n Affine constraints :";
for(vector<vector<Inequation*> >::iterator it=GetAffineDomain()->begin(); it != GetAffineDomain()->end(); ++it){
   result+="\n";
   for(vector<Inequation*>::iterator iti=(*it).begin(); iti != (*it).end(); ++iti)
      result+="\t"+(*iti)->Print_str();
   }

result+="\nNon Affine constraints :";
for(vector<vector<Inequation*> >::iterator it=GetNonAffineDomain()->begin(); it != GetNonAffineDomain()->end(); ++it){
   result+="\n";
   for(vector<Inequation*>::iterator iti=(*it).begin(); iti != (*it).end(); ++iti)
      result+="\t"+(*iti)->Print_str();
   }
result+="\n";
if(!IsIfElse())
   return result;


result+="\n Affine NOT DOMAIN :";
for(vector<vector<Inequation*> >::iterator it=GetAffineElseDomain()->begin(); it != GetAffineElseDomain()->end(); ++it){
   result+="\n";
   for(vector<Inequation*>::iterator iti=(*it).begin(); iti != (*it).end(); ++iti)
      result+="\t"+(*iti)->Print_str();
   }

result+="\nNon Affine  NOT_DOMAIN :";
for(vector<vector<Inequation*> >::iterator it=GetNonAffineElseDomain()->begin(); it != GetNonAffineElseDomain()->end(); ++it){
   result+="\n";
   for(vector<Inequation*>::iterator iti=(*it).begin(); iti != (*it).end(); ++iti)
      result+="\t"+(*iti)->Print_str();
   }
result+="\n";

return result;
}
Esempio n. 6
0
OSStatus MouseHandler(EventHandlerCallRef next,
		      EventRef event, void *data)
{
    HIViewRef control;
    WindowRef window;
    ControlKind view;
    UInt32 kind;

    // Get the event kind

    kind = GetEventKind(event);

    // Get the window

    GetEventParameter(event, kEventParamWindowRef,
                      typeWindowRef, NULL, sizeof(window),
                      NULL, &window);

    // Get the view

    HIViewGetViewForMouseEvent(HIViewGetRoot(window), event,
			       &control);

    // Get the control kind

    GetControlKind(control, &view);

    // Switch on event kind

    switch (kind)
    {
        // Mouse down

    case kEventMouseDown:

        // Switch on control kind

        switch (view.kind)
        {
            // Combo box

        case kControlKindHIComboBox:

            // Do nothing, let the default event handler do it's thing

            break;

            // Everything else

        default:

            // Clear the keyboard focus, otherwise the focus stays on the
            // combo box and makes it drop down when the user presses a key

            ClearKeyboardFocus(window);
            break;
        }

    default:
        return eventNotHandledErr;
    }

    // Return event not handled so that the default event handler gets
    // to do it's thing

    return eventNotHandledErr;
}
Esempio n. 7
0
void	AUCarbonViewControl::ParameterToControl(Float32 paramValue)
{
#if !__LP64__
	++mInControlInitialization;
	switch (mType) {
	case kTypeContinuous:
		SetValueFract(AUParameterValueToLinear(paramValue, &mParam));
		break;
	case kTypeDiscrete:
		{
			long value = long(paramValue);
			
			// special case [1] -- menu parameters
			if (mParam.HasNamedParams()) {
				// if we're dealing with menus they behave differently!
				// becaue setting min and max doesn't work correctly for the control value
				// first menu item always reports a control value of 1
				ControlKind ctrlKind;
				if (GetControlKind(mControl, &ctrlKind) == noErr) {
					if ((ctrlKind.kind == kControlKindPopupArrow) 
						|| (ctrlKind.kind == kControlKindPopupButton))				
					{
						value = value - long(mParam.ParamInfo().minValue) + 1;
					}
				}
			}
			
			// special case [2] -- Write-only boolean parameters
			AudioUnitParameterInfo AUPI = mParam.ParamInfo();
			
			bool isWriteOnlyBoolParameter = (	(AUPI.unit == kAudioUnitParameterUnit_Boolean) &&
												(AUPI.flags & kAudioUnitParameterFlag_IsWritable) &&
												!(AUPI.flags & kAudioUnitParameterFlag_IsReadable)	);
			if (!isWriteOnlyBoolParameter) {
				SetValue (value);
			}
		}
		break;
	case kTypeText:
		{
			CFStringRef cfstr = mParam.GetStringFromValueCopy(&paramValue);

			if ( !(mParam.ParamInfo().flags & kAudioUnitParameterFlag_IsWritable)			//READ ONLY PARAMS
					&& (mParam.ParamInfo().flags & kAudioUnitParameterFlag_IsReadable)) 
			{
				if (mParam.GetParamTag()) {
					CFMutableStringRef str = CFStringCreateMutableCopy(NULL, 256, cfstr);
					CFRelease (cfstr);
					CFStringAppend (str, CFSTR(" "));
					CFStringAppend (str, mParam.GetParamTag());
					cfstr = str;
				}
			}
			SetTextValue(cfstr);
			CFRelease (cfstr);
		}
		break;
	}
	--mInControlInitialization;
#endif
}