Example #1
0
McoStatus DisplayDialog::DoEvents(short item, Point clickPoint, WindowCode *wc, int32 *numwc, void **data, Boolean &changed)
{
UserItemUPP myfilter;
Str255		theString;
short		itemtype;
Handle		cn1,sliderControl;
Rect		r;
short		part;
Point		mpoint;
int32		next_patch;
McoStatus	status;
WindowPtr	oldp;
int32		temp;
double 		m=1;

	GetPort(&oldp);
	SetPort(dp);

	Changed = FALSE;
	*numwc = 0;
	status = MCO_SUCCESS;

	if (isPressed(0x38)) m = 10;

	if (item != -1) {
		if (item == ids[Slider])   // the slider has been adjusted
			{
			GetMouse(&mpoint);
			do {
				current_patch = GetSlider(mpoint,ids[Slider]);
				ShowPatchScroll(current_patch);
				SetSheetStripText();
				current_sheet = current_patch/(patch_per_strip*strip_per_sheet);
				current_strip = (current_patch - current_sheet*(patch_per_strip*strip_per_sheet))/patch_per_strip;	
				GetMouse(&mpoint);
				} while ( StillDown ( ) );
			checkError((current_patch/patch_per_strip)*patch_per_strip);
			//_waiting = 0;
			Enable(dp,ids[Redo]);
			SetSheetStripText();
			}
		else if (item == ids[Strip_Rect])
			{
			GlobalToLocal(&clickPoint);
			temp = whichPatch(clickPoint);
			if (temp != -1)
				{
				current_patch = temp;
				current_disp = current_patch-current_top;
				GetDItem ( dp, ids[Slider], &itemtype, (Handle*)&sliderControl, &r );
				SetCtlValue ( (ControlHandle)sliderControl,current_patch);
				ShowPatch(current_patch);
				SetSheetStripText();
				}
			}
		}
	SetPort(oldp);
	return status;	    	
}
Example #2
0
bool structGraphicsScreen :: v_mouseStillDown () {
	#if cairo
		if (theMouseDown) return true;
		else { theMouseDown = true; return false; }
	#elif cocoa
		return false;
	#elif win
		return motif_win_mouseStillDown ();
	#elif mac
		return StillDown ();
	#endif
}
Example #3
0
static PyObject *Evt_StillDown(PyObject *_self, PyObject *_args)
{
    PyObject *_res = NULL;
    Boolean _rv;
#ifndef StillDown
    PyMac_PRECHECK(StillDown);
#endif
    if (!PyArg_ParseTuple(_args, ""))
        return NULL;
    _rv = StillDown();
    _res = Py_BuildValue("b",
                         _rv);
    return _res;
}
Example #4
0
static void handlemouse (EventRecord *ev) {

	short part;
	WindowPtr w;
	
	part = FindWindow ((*ev).where, &w);
	
	if (w != nil) 
	
		if (w != FrontWindow ()) { /*just like all other Mac programs*/
			
			SelectWindow (w);
							
			return; /*the mouse click is consumed by the bringtofront operation*/
			}
	
	switch (part) {
	
		case inMenuBar: 
			handlemenu (MenuSelect ((*ev).where)); 
			
			break;
		
		case inSysWindow:
			SystemClick (ev, w); 
			
			break;
		
		case inDrag:
			handledrag (ev, w);
			
			break;
		
		case inContent:
			EnableSharedMenus (false);
			
			while (StillDown ())
				;
			
			EnableSharedMenus (true);
			
			break;
			
		} /*switch*/
	} /*handlemouse*/
Example #5
0
void TActiveScroller::IndicatorProc(Point origPoint)
{
	#if TARGET_API_MAC_CARBON==1
		UPortSaver			safe(GetControlOwner(scrollBar));		
	#else
		UPortSaver			safe((**scrollBar).contrlOwner);
	#endif
	Point				lastPoint,currentPoint;
	short				value;
	short				originalValue=GetScrollBarValue();
	
	// While we're tracking the thumb, we're calculating its value based
	// on the current mouse location.  That works great, assuming you
	// clicked _exactly_ in the center of the thumb.  We calculate how
	// much we need to compensate the value caluculations based on the
	// click distance from the center of the thumb.	
	valueSlop=0;		// Important as the valueSlop is used in the CalcScrollBarValueFromPoint proc
	valueSlop=originalValue-CalcScrollBarValueFromPoint(origPoint);
	currentPoint=lastPoint=origPoint;

	while (StillDown())
	{
		// Only attempt to update the value if the mouse moved.
		GetMouse(&currentPoint);
		
		if (EqualPt(currentPoint,lastPoint))
			continue;
		
		// Remeber where the last mouse location was 
		lastPoint=currentPoint;				
		
		// Check to see if the user tracked outside of the slop rect.
		// If they did, restore the original value of the control.
		// This mimics the same behaviour as the standard scroll bar.
		if (FPointInRect(currentPoint,trackRect))
			value=CalcScrollBarValueFromPoint(currentPoint);
		else
			value=originalValue;
		
		value=Limit(value,::GetControlMinimum(scrollBar),::GetControlMaximum(scrollBar));
		
		SetScrollBarValue(value);
	}
}
Example #6
0
/*===================================
	HandleMouseDown
====================================*/
void PTDropperAction::HandleMouseDown( const SMouseDownEvent &inEvent )
{
	Point			pt;
	Color32			newColor;
	StSaveGWorld	aGWorldSaver;

		// get the initial color
	if ( this->GetColorUnderPoint( inEvent.whereLocal, &newColor ) )
		this->ChangeColor( newColor, (inEvent.macEvent.modifiers & shiftKey) ? true : false );
		
		// loop until the mouse is released
	while( StillDown() )
	{
		SUMiscUtils::GetMouseRelativeToView( mSettings.theCanvas, &pt );	
		
		if ( this->GetColorUnderPoint( pt, &newColor ) )
			this->ChangeColor( newColor, SUMiscUtils::IsShiftKey() );
	}
	
		// delete this object (since mAffectsUndoState == false)
	this->PostAsAction();	
}
Example #7
0
McoStatus TechkonDialog::DoEvents(short item, Point clickPoint, WindowCode *wc, int32 *numwc, void **data, Boolean &changed)
{
UserItemUPP myfilter;
Str255		theString;
short		itemtype;
Handle		cn1,sliderControl;
Rect		r;
short		part;
Point		mpoint;
int32		next_patch;
McoStatus	status;
WindowPtr	oldp;
int32		temp;
double 		m=1;

	GetPort(&oldp);
	SetPort(dp);

	Changed = FALSE;
	*numwc = 0;
	status = MCO_SUCCESS;

	if (isPressed(0x38)) m = 10;

	if (item != -1) {
		if ((item == TIMER_ITEM ) && (doc->tcom)) // a timer event has occured
			{   
			_last_tick_time2 = TickCount();
			if (_waiting)
				{
				if (!doc->tcom->IsBufferEmpty())	// has a strip been read in
					{
					changed = TRUE; 
					// check to see if a strip has been read in 
					if (doc->tcom->IsDataPresent()) 
						{
						doc->needsSave = TRUE;
						GetDItem ( dp,ids[Message], &itemtype, (Handle*)&cn1, &r );
						GetIndString(theString,Message_List_ID,4);
						SetIText(cn1,theString);
						readInPatches();
						Changed = TRUE;
						next_patch = findNextPatch();
						if (next_patch == -1)
							{
							GetDItem ( dp,ids[Message], &itemtype, (Handle*)&cn1, &r );
							GetIndString(theString,Message_List_ID,5);
							SetIText(cn1,theString);
							_done == TRUE;
							_waiting = FALSE;
							Disable(dp,ids[Redo]);
							Disable(dp,ids[Start]);
							Disable(dp,ids[Cancel]);
							Enable(dp,ids[Save_as]);	
							Enable(dp,OK);			
							}
						else
							{
							GetDItem ( dp,ids[Message], &itemtype, (Handle*)&cn1, &r );
							GetIndString(theString,Message_List_ID,7);
							SetIText(cn1,theString);
							}
						}
					}
				checkFinished();
				}
			}
		else if (item == ids[Slider])   // the slider has been adjusted
			{
			GetMouse(&mpoint);
			do {
				current_patch = GetSlider(mpoint,ids[Slider]);
				ShowPatchScroll(current_patch);
				SetSheetStripText();
				current_sheet = current_patch/(patch_per_strip*strip_per_sheet);
				current_strip = (current_patch - current_sheet*(patch_per_strip*strip_per_sheet))/patch_per_strip;	
				GetMouse(&mpoint);
				} while ( StillDown ( ) );
			checkError((current_patch/patch_per_strip)*patch_per_strip);
			//_waiting = 0;
			Enable(dp,ids[Redo]);
			SetSheetStripText();
			}
		else if (item == ids[Start]) // start or stop reading
			{
			status = MCO_SUCCESS;
			if (_first) 
				{
				
				status = doc->tcom->Calibrate();
				playSound(EndColumnNum);
				if (status != MCO_SUCCESS) 
					{
					McoMessAlert(MCO_FAIL_CALIB,0L);
					status = MCO_SUCCESS;
					goto bail;
					}
				}
			if (status == MCO_SUCCESS)
				{
				_waiting = 1;	
				current_patch = findNextPatch();  // reset the display, current patch, sheet, strip, and text
				ShowPatch(current_patch); // display the window
				current_sheet = current_patch/(patch_per_strip*strip_per_sheet);
				current_strip = (current_patch - current_sheet*(patch_per_strip*strip_per_sheet))/patch_per_strip;
				Disable(dp,ids[Start]);	 
				GetDItem ( dp,ids[Message], &itemtype, (Handle*)&cn1, &r );
				GetIndString(theString,Message_List_ID,7);
				SetIText(cn1,theString);
				SetSheetStripText();		
				_first = 0;
				}
			status = MCO_SUCCESS;
			}
		else if (item == ids[Save_as])
			{
			StorePatches();
			doc->patchtype = patchtype;
			doc->handle_save_datafile(patchD);
			ShowPatch(current_patch);
			}
		else if (item == ids[VoiceSet]) 
			{
			GetDItem(dp, ids[VoiceSet], &itemtype, (Handle*)&cn1, &r );
			voice_set = GetCtlValue((ControlHandle)cn1);
			}
		else if (item == ids[Strip_Rect])
			{
			GlobalToLocal(&clickPoint);
			temp = whichPatch(clickPoint);
			if (temp != -1)
				{
				current_patch = temp;
				current_disp = current_patch-current_top;
				GetDItem ( dp, ids[Slider], &itemtype, (Handle*)&sliderControl, &r );
				SetCtlValue ( (ControlHandle)sliderControl,current_patch);
				ShowPatch(current_patch);
				SetSheetStripText();
				}
			}
		else if (item == ids[Redo]) // Reread a strip
			{
			_waiting = 1;		   // reset the display, current patch, sheet, strip, and text
			Disable(dp,ids[Redo]);
			Disable(dp,ids[Start]);	 
			GetDItem ( dp,ids[Message], &itemtype, (Handle*)&cn1, &r );
			GetIndString(theString,Message_List_ID,7);
			SetIText(cn1,theString);
			}
		else if (item == OK)
			{
			StorePatches();
			doc->copyWaiting(patchD);
			doc->patchtype = patchtype;
			//doc->needsSave = TRUE;
			*numwc = 1;
			wc[0].code = WE_Close_Window;
			wc[0].wintype = WinType;
			wc[0].winnum = WinNum;
			wc[0].doc = doc;
			}
		else if (item == Cancel)
			{
			*numwc = 1;
			wc[0].code = WE_Close_Window;
			wc[0].wintype = WinType;
			wc[0].winnum = WinNum;
			wc[0].doc = doc;
			}
		}
bail:		
		
	SetPort(oldp);
	changed = Changed;
	return status;	    	
}
Example #8
0
int dGetKeyState(int key)
{
	#ifdef _MSC_VER	
		return GetAsyncKeyState (key);
	#else
	
		UInt32 state;
		static bool haveKeyMap = false;
		static char virtualKeyCode[128];
		
		if (!haveKeyMap) {
			haveKeyMap = true;
			state = 0;
			memset (virtualKeyCode, 0, sizeof (virtualKeyCode));
			// this is an adbomination, the function, doe not agree with the function GetKey
			//for (int i = 0; i < 128; i ++) {
				//int val = KeyTranslate (NULL, i, &state);
				//virtualKeyCode[val] = i;
			//}
			
			// hardcoding the key mapping, if some one figure out how to make thois work please let me know
			virtualKeyCode[VK_ESCAPE] = 46;       // scappe key
			virtualKeyCode[VK_LBUTTON] = 35;
			virtualKeyCode[VK_F1] = 0x63;
			virtualKeyCode[VK_F2] = 0x61;
			virtualKeyCode[VK_F3] = 0x7b;
			
			virtualKeyCode[int('a')] = 25;
			virtualKeyCode[int('A')] = 25;
			virtualKeyCode[int('d')] = 27;
			virtualKeyCode[int('D')] = 27;
			virtualKeyCode[int('w')] = 22;
			virtualKeyCode[int('W')] = 22;
			virtualKeyCode[int('s')] = 26;
			virtualKeyCode[int('S')] = 26;
		}
	
		if (key == VK_LBUTTON) {
			if (StillDown()){
				return 0x8000;
			}
			return 0;
		} 
					
		KeyMap theKeys;
		GetKeys (theKeys);
			
		int index;
		index = 0;
		
		for (int i = 0; i <4; i ++) {
			if (theKeys[i]) {
			   for (int mask = theKeys[i]; mask; mask >>= 1) {
					index ++;
			   }
			   if (virtualKeyCode[key] == index) {
					return 0x8000;
			   }
			}
			index += 32;
		}
		//statte = theKey.
		return 0;
	#endif

}
Example #9
0
/*==================================
	PTTrackingPaintAction::HandleMouseDown
===================================*/
void PTTrackingPaintAction::HandleMouseDown( const SMouseDownEvent &inMouseDown )
{
	Point				newMousePt, prevMousePt;
	SInt32				prevRow = -1, prevCol = -1, newRow = -1, newCol = -1;
	StSaveGWorld		aSaver;						// save/restore gdevice & port
	
	/*********************************************
		see where the mouse went down within the canvas
	*********************************************/	
	if ( !mSettings.theCanvas->MapPointToCell( inMouseDown.whereLocal, &mMouseDownCol, &mMouseDownRow ) )
		return;			// missed it
	
	/*********************************************
		prepare for drawing
	*********************************************/	
	mSettings.currentBuffer->ResetPen();
	mSettings.scratchBuffer->ResetPen();
	
	mSettings.theCanvas->FocusDraw();
	prevMousePt = inMouseDown.whereLocal;
	if ( mAffectsUndoState )
		mSettings.thePaintView->CopyToUndo();
	
	/*********************************************
		this lets the subclass know the mouse went down
	*********************************************/	
	this->MouseInitial( inMouseDown, mMouseDownCol, mMouseDownRow );
	
	/*********************************************
		loop until the mouse is released
	*********************************************/	
	while( StillDown() )
	{
		/*********************************************
			Get the current mouse location, relative to the superview of the canvas
		*********************************************/
		SUMiscUtils::GetMouseRelativeToView( mSettings.theCanvas, &newMousePt );

		/*********************************************
			convert this into a col/row within the bitmap
		*********************************************/
		mSettings.theCanvas->MapPointToCell( newMousePt, &newCol, &newRow );

		/*********************************************
			if the shift key is down, snap to the 45 or 90 degrees
		*********************************************/
		mSnapTo.SnapTo( mMouseDownCol, mMouseDownRow, newCol, newRow, &newCol, &newRow );		
		
		/*********************************************
			Call the subclass to handle the tool tracking
		*********************************************/	
		this->MouseStillDown( inMouseDown, prevMousePt, newMousePt, prevCol, prevRow, newCol, newRow );

		/*********************************************
			prepare for next loop
		*********************************************/	
		prevMousePt = newMousePt;
		prevRow = newRow;
		prevCol = newCol;
	}
	
	/*********************************************
		Send a final call to the subclass
	*********************************************/
	mAffectsUndoState = this->MouseFinal( inMouseDown, prevMousePt, newMousePt, prevCol, prevRow, newCol, newRow );

	/*********************************************
		this will post the action if undoable, or just delete the object
	*********************************************/
	this->PostAsAction();
}
Example #10
0
McoStatus SpChInDialog::DoEvents(short item, Point clickPoint, WindowCode *wc, int32 *numwc, void **data, Boolean &changed)
{
UserItemUPP myfilter;
Str255		theString;
short		itemtype;
Handle		cn1,sliderControl;
Rect		r;
short		part;
Point		mpoint;
int32		next_patch;
McoStatus	status;
WindowPtr	oldp;
int32		temp;
double 		m=1;
SpectroChart *tcom = (SpectroChart*)(doc->tcom);


	GetPort(&oldp);
	SetPort(dp);

	Changed = FALSE;
	*numwc = 0;
	status = MCO_SUCCESS;

	if (isPressed(0x38)) m = 10;

	if (item != -1) {
		if (item == TIMER_ITEM ) // a timer event has occured
			{   
			_last_tick_time2 = TickCount();
			if (_waiting)
				{
				doc->needsSave = TRUE;
			//	GetDItem ( dp,Message, &itemtype, (Handle*)&cn1, &r );
			//	GetIndString(theString,Message_List_ID,4);
			//	SetIText(cn1,theString);
				readInPatches();
				Changed = TRUE;
				next_patch = findNextPatch();
				if (next_patch == -1)
					{
				//	GetDItem ( dp,Message, &itemtype, (Handle*)&cn1, &r );
				//	GetIndString(theString,Message_List_ID,5);
				//	SetIText(cn1,theString);
					_done == TRUE;
					if (current_patch == total_patches) _waiting = FALSE;
					Disable(dp,ids[Redo]);
					//Disable(dp,ReadNext);
					if (NotAlreadFinished) Disable(dp,Cancel);
					Enable(dp,ids[Save_as]);	
					Enable(dp,OK);			
					}
				else
					{

				//	GetDItem ( dp,Message, &itemtype, (Handle*)&cn1, &r );
				//	GetIndString(theString,Message_List_ID,2);
				//	SetIText(cn1,theString);
					}
				if (!_waiting)
					{
					GetDItem ( dp,ids[Start], &itemtype, (Handle*)&cn1, &r );
					GetIndString(theString,Button_Labels,1);
					SetCTitle((ControlHandle)cn1,theString);
					}
				checkFinished();
				}
			}
		else if (item == ids[Slider])   // the slider has been adjusted
			{
			GetMouse(&mpoint);
			do {
				current_patch = GetSlider(mpoint,ids[Slider]);
				ShowPatchScroll(current_patch);
				SetSheetStripText();
				current_sheet = current_patch/(patch_per_strip*strip_per_sheet);
				current_strip = (current_patch - current_sheet*(patch_per_strip*strip_per_sheet))/patch_per_strip;	
				GetMouse(&mpoint);
				} while ( StillDown ( ) );
			checkError((current_patch/patch_per_strip)*patch_per_strip);
			//_waiting = 0;
			Enable(dp,ids[Redo]);
			SetSheetStripText();
			}
		else if (item == ids[Start]) // start or stop reading
			{
			if (_waiting) 
				{
				_waiting = 0;
				GetDItem ( dp,ids[Start], &itemtype, (Handle*)&cn1, &r );
				GetIndString(theString,Button_Labels,1);
				SetCTitle((ControlHandle)cn1,theString);
				current_patch = last_patch;
				ShowPatchScroll(current_patch);
				SetSheetStripText();
				current_sheet = current_patch/(patch_per_strip*strip_per_sheet);
				current_strip = (current_patch - current_sheet*(patch_per_strip*strip_per_sheet))/patch_per_strip;
				}
			else 
				{
				if (DoStart() == MCO_SUCCESS)
					{
					GetDItem ( dp,ids[Start], &itemtype, (Handle*)&cn1, &r );
					GetIndString(theString,Button_Labels,2);
					SetCTitle((ControlHandle)cn1,theString);
					}
				}
			}
		else if (item == ids[Position_Up])
			{
			if (!_waiting)
				{
				tcom->moveDistance(0,m*0.5);
				}
			}
		else if (item == ids[Position_Down])
			{
			if (!_waiting)
				{	
				tcom->moveDistance(0,-0.5*m);
				}
			}
		else if (item == ids[Position_Left])
			{
			if (!_waiting)
				{
				tcom->moveDistance(-0.5*m,0);
				}
			}
		else if (item == ids[Position_Right])
			{
			if (!_waiting)
				{
				tcom->moveDistance(0.5*m,0);
				}
			}		
		else if (item == ids[Save_as])
			{
			StorePatches();
			doc->patchtype = patchtype;
			doc->handle_save_datafile(patchD);
			ShowPatch(current_patch);
			}
		else if (item == ids[VoiceSet]) 
			{
			GetDItem(dp, ids[VoiceSet], &itemtype, (Handle*)&cn1, &r );
			voice_set = GetCtlValue((ControlHandle)cn1);
			}
		else if (item == ids[Strip_Rect])
			{
			GlobalToLocal(&clickPoint);
			temp = whichPatch(clickPoint);
			if (temp != -1)
				{
				current_patch = temp;
				current_disp = current_patch-current_top;
				GetDItem ( dp, ids[Slider], &itemtype, (Handle*)&sliderControl, &r );
				SetCtlValue ( (ControlHandle)sliderControl,current_patch);
				ShowPatch(current_patch);
				SetSheetStripText();
				}
			}
		else if (item == OK)
			{
			StorePatches();
			doc->copyWaiting(patchD);
			doc->patchtype = patchtype;
			//doc->needsSave = TRUE;
			*numwc = 1;
			wc[0].code = WE_Close_Window;
			wc[0].wintype = WinType;
			wc[0].winnum = WinNum;
			wc[0].doc = doc;
			}
		else if (item == Cancel)
			{
			*numwc = 1;
			wc[0].code = WE_Close_Window;
			wc[0].wintype = WinType;
			wc[0].winnum = WinNum;
			wc[0].doc = doc;
			doc->patchtype = oldpatchtype;
			}
		}
	SetPort(oldp);
	changed = Changed;
	return status;	    	
}