NS_IMETHODIMP nsScrollbarButtonFrame::HandleEvent(nsPresContext* aPresContext, nsGUIEvent* aEvent, nsEventStatus* aEventStatus) { // XXX hack until handle release is actually called in nsframe. if (aEvent->message == NS_MOUSE_EXIT_SYNTH|| aEvent->message == NS_MOUSE_RIGHT_BUTTON_UP || aEvent->message == NS_MOUSE_LEFT_BUTTON_UP) HandleRelease(aPresContext, aEvent, aEventStatus); return nsButtonBoxFrame::HandleEvent(aPresContext, aEvent, aEventStatus); }
NS_IMETHODIMP nsScrollbarButtonFrame::HandleEvent(nsPresContext* aPresContext, nsGUIEvent* aEvent, nsEventStatus* aEventStatus) { // XXX hack until handle release is actually called in nsframe. if (aEvent->message == NS_MOUSE_EXIT_SYNTH || aEvent->message == NS_MOUSE_BUTTON_UP) HandleRelease(aPresContext, aEvent, aEventStatus); // if we didn't handle the press ourselves, pass it on to the superclass if (!HandleButtonPress(aPresContext, aEvent, aEventStatus)) return nsButtonBoxFrame::HandleEvent(aPresContext, aEvent, aEventStatus); return NS_OK; }
void CChannelHandler::HandleNoteData(stChanNote *pNoteData, int EffColumns) { int LastInstrument = m_iInstrument; int Instrument = pNoteData->Instrument; int Note = pNoteData->Note; // Clear the note cut effect if (pNoteData->Note != NONE) { m_iNoteCut = 0; } // Effects for (int n = 0; n < EffColumns; n++) { unsigned char EffNum = pNoteData->EffNumber[n]; unsigned char EffParam = pNoteData->EffParam[n]; HandleCustomEffects(EffNum, EffParam); } // Instrument if (Note == HALT || Note == RELEASE) Instrument = MAX_INSTRUMENTS; // Ignore instrument for release and halt commands if (Instrument != MAX_INSTRUMENTS) m_iInstrument = Instrument; bool Trigger = (Note != NONE) && (Note != HALT) && (Note != RELEASE); bool NewInstrument = (m_iInstrument != LastInstrument) || (m_iInstrument == MAX_INSTRUMENTS); if (m_iInstrument == MAX_INSTRUMENTS) { // No instrument selected, default to 0 m_iInstrument = 0; } if (NewInstrument || Trigger) { if (!HandleInstrument(m_iInstrument, Trigger, NewInstrument)) return; } // Volume if (pNoteData->Vol < 0x10) { m_iVolume = pNoteData->Vol << VOL_SHIFT; } // Clear release flag if (pNoteData->Note != RELEASE && pNoteData->Note != NONE) { m_bRelease = false; } // Note switch (pNoteData->Note) { case NONE: HandleEmptyNote(); break; case HALT: HandleHalt(); break; case RELEASE: HandleRelease(); break; default: HandleNote(pNoteData->Note, pNoteData->Octave); break; } }
NS_IMETHODIMP nsSliderFrame::HandleEvent(nsPresContext* aPresContext, nsGUIEvent* aEvent, nsEventStatus* aEventStatus) { NS_ENSURE_ARG_POINTER(aEventStatus); if (nsEventStatus_eConsumeNoDefault == *aEventStatus) { return NS_OK; } nsIBox* scrollbarBox = GetScrollbar(); nsCOMPtr<nsIContent> scrollbar; scrollbar = GetContentOfBox(scrollbarBox); PRBool isHorizontal = IsHorizontal(); if (isDraggingThumb()) { switch (aEvent->message) { case NS_MOUSE_MOVE: { nsPoint eventPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, this); if (mChange) { // We're in the process of moving the thumb to the mouse, // but the mouse just moved. Make sure to update our // destination point. mDestinationPoint = eventPoint; StopRepeat(); StartRepeat(); break; } nscoord pos = isHorizontal ? eventPoint.x : eventPoint.y; nsIFrame* thumbFrame = mFrames.FirstChild(); if (!thumbFrame) { return NS_OK; } // take our current position and subtract the start location pos -= mDragStart; PRBool isMouseOutsideThumb = PR_FALSE; if (gSnapMultiplier) { nsSize thumbSize = thumbFrame->GetSize(); if (isHorizontal) { // horizontal scrollbar - check if mouse is above or below thumb // XXXbz what about looking at the .y of the thumb's rect? Is that // always zero here? if (eventPoint.y < -gSnapMultiplier * thumbSize.height || eventPoint.y > thumbSize.height + gSnapMultiplier * thumbSize.height) isMouseOutsideThumb = PR_TRUE; } else { // vertical scrollbar - check if mouse is left or right of thumb if (eventPoint.x < -gSnapMultiplier * thumbSize.width || eventPoint.x > thumbSize.width + gSnapMultiplier * thumbSize.width) isMouseOutsideThumb = PR_TRUE; } } if (isMouseOutsideThumb) { SetCurrentThumbPosition(scrollbar, mThumbStart, PR_FALSE, PR_TRUE, PR_FALSE); return NS_OK; } // set it SetCurrentThumbPosition(scrollbar, pos, PR_FALSE, PR_TRUE, PR_TRUE); // with snapping } break; case NS_MOUSE_BUTTON_UP: if (static_cast<nsMouseEvent*>(aEvent)->button == nsMouseEvent::eLeftButton || (static_cast<nsMouseEvent*>(aEvent)->button == nsMouseEvent::eMiddleButton && gMiddlePref)) { // stop capturing AddListener(); DragThumb(PR_FALSE); if (mChange) { StopRepeat(); mChange = 0; } //we MUST call nsFrame HandleEvent for mouse ups to maintain the selection state and capture state. return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus); } } //return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus); return NS_OK; } else if ((aEvent->message == NS_MOUSE_BUTTON_DOWN && static_cast<nsMouseEvent*>(aEvent)->button == nsMouseEvent::eLeftButton && #ifdef XP_MACOSX // On Mac the option key inverts the scroll-to-here preference. (static_cast<nsMouseEvent*>(aEvent)->isAlt != GetScrollToClick())) || #else (static_cast<nsMouseEvent*>(aEvent)->isShift != GetScrollToClick())) || #endif (gMiddlePref && aEvent->message == NS_MOUSE_BUTTON_DOWN && static_cast<nsMouseEvent*>(aEvent)->button == nsMouseEvent::eMiddleButton)) { nsPoint eventPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, this); nscoord pos = isHorizontal ? eventPoint.x : eventPoint.y; // adjust so that the middle of the thumb is placed under the click nsIFrame* thumbFrame = mFrames.FirstChild(); if (!thumbFrame) { return NS_OK; } nsSize thumbSize = thumbFrame->GetSize(); nscoord thumbLength = isHorizontal ? thumbSize.width : thumbSize.height; // set it nsWeakFrame weakFrame(this); // should aMaySnap be PR_TRUE here? SetCurrentThumbPosition(scrollbar, pos - thumbLength/2, PR_FALSE, PR_FALSE, PR_FALSE); NS_ENSURE_TRUE(weakFrame.IsAlive(), NS_OK); DragThumb(PR_TRUE); if (isHorizontal) mThumbStart = thumbFrame->GetPosition().x; else mThumbStart = thumbFrame->GetPosition().y; mDragStart = pos - mThumbStart; } // XXX hack until handle release is actually called in nsframe. // if (aEvent->message == NS_MOUSE_EXIT_SYNTH || aEvent->message == NS_MOUSE_RIGHT_BUTTON_UP || aEvent->message == NS_MOUSE_LEFT_BUTTON_UP) // HandleRelease(aPresContext, aEvent, aEventStatus); if (aEvent->message == NS_MOUSE_EXIT_SYNTH && mChange) HandleRelease(aPresContext, aEvent, aEventStatus); return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus); }