GestureRecognizer::RecognizeFlag GestureRecognizerDoubleClick::recognize(Gesture* ges, MotionAction action, int num, float xs[], float ys[]) {{ GestureRecognizer::RecognizeFlag retFlag = RecognizeFlag_Invaild; GestureDoubleClick* doubleClick = static_cast<GestureDoubleClick*>(ges); if (!doubleClick) return retFlag; GestureState state = doubleClick->state(); if (num == 0) { printf("recognize failed, get 0 touches\n"); return retFlag; } if (num > 1) { setIgnore(true); } if (ignore()) { doubleClick->clear(); return retFlag; } unsigned int manhLength = 0; unsigned int elapsedTime = 0; switch (action) { case MotionAction_Down: { GestureDoubleClick::PressInfo info; info.point = GesturePoint(xs[0], ys[0]); info.pressTime = currentTime(); if (doubleClick->pressNum() == 1) { manhLength = _manhattan_length_(doubleClick->pressInfo(0).point, GesturePoint(xs[0], ys[0])); elapsedTime = currentTime() - doubleClick->pressInfo(0).pressTime; // FIXME: gesture config if (manhLength > D2 || elapsedTime > T2) { doubleClick->clear(); return retFlag; } } doubleClick->setPressInfo(info); } break; case MotionAction_Up: { if (num == 1) { GesturePoint lastPoint; if (doubleClick->pressNum() == 1) lastPoint = doubleClick->pressInfo(0).point; else if (doubleClick->pressNum() == 2) lastPoint = doubleClick->pressInfo(1).point; else {} manhLength = _manhattan_length_(lastPoint, GesturePoint(xs[0], ys[0])); elapsedTime = currentTime() - doubleClick->pressInfo(0).pressTime; if (manhLength > D1 || elapsedTime > T1) { doubleClick->clear(); return retFlag; } if (doubleClick->pressNum() == 2) { doubleClick->setPoint(GesturePoint(xs[0], ys[0])); doubleClick->setState(GestureState_Triggered); retFlag = RecognizeFlag_Triggered; } } } break; case MotionAction_Pointer_Down: case MotionAction_Pointer_Up: { setIgnore(true); } break; case MotionAction_Move: { if (num == 1) { GesturePoint lastPoint; if (doubleClick->pressNum() == 1) lastPoint = doubleClick->pressInfo(0).point; else if (doubleClick->pressNum() == 2) lastPoint = doubleClick->pressInfo(1).point; else {} manhLength = _manhattan_length_(lastPoint, GesturePoint(xs[0], ys[0])); elapsedTime = currentTime() - doubleClick->pressInfo(0).pressTime; if (manhLength > D1 || elapsedTime > T1) { doubleClick->clear(); return retFlag; } } } break; default: break; } return retFlag; }
void StyleDialog::styleSetIgnoreAll ( bool ignore ) { int count = table->GetItemCount(); for ( int i = 0; i < count; ++i ) setIgnore ( i, ignore ); }
void StyleDialog::OnItemActivated ( wxListEvent& event ) { int index = event.GetIndex(); bool ignore = ( getTextByColumn ( table, index, 6 ) == _ ( "Ignore" ) ); setIgnore ( index, ( ignore ) ? false : true ); }
void StyleDialog::OnReport ( wxCommandEvent& event ) { table->DeleteAllItems(); matchVector.clear(); status->SetStatusText ( _ ( "Checking document..." ) ); // update presets ruleSetPreset = ruleSetCombo->GetValue(); filterPreset = filterCombo->GetValue(); // reconstitute short filenames wxString ruleSet, filter; ruleSet = ruleSetPreset + _T ( ".xml" ); ruleSet.Replace ( _(" "), _T("_") ); filter = filterPreset + _T ( ".xml" ); wxString separator = wxFileName::GetPathSeparator(); std::auto_ptr<HouseStyle> hs ( new HouseStyle ( (type == ID_TYPE_SPELL) ? HS_TYPE_SPELL : HS_TYPE_STYLE, bufferUtf8, ruleSetDirectory, ruleSet, filterDirectory, filter, separator, #ifdef __WXMSW__ aspellDataPath, aspellDictPath, #endif 5 ) ); status->SetStatusText ( _ ( "Checking document..." ) ); if ( !hs->createReport() ) { const wxString &error = hs->getLastError(); status->SetStatusText ( _ ( "Cannot check document: " ) + error ); return; } matchVector = hs->getMatchVector(); vector<ContextMatch>::iterator it; std::string prelogUtf8, matchUtf8, postlogUtf8, replaceUtf8, reportUtf8; wxString matchNo, prelog, match, postlog, replace, report; int i = 0; for ( it = matchVector.begin(); it != matchVector.end(); ++it ) { matchNo.Printf ( _T ( "%i" ), i + 1 ); // display numbers from 1 prelogUtf8 = flatWhiteSpace ( ( *it ).prelog ); matchUtf8 = flatWhiteSpace ( ( *it ).match ); postlogUtf8 = flatWhiteSpace ( ( *it ).postlog ); replaceUtf8 = flatWhiteSpace ( ( *it ).replace ); reportUtf8 = flatWhiteSpace ( ( *it ).report ); prelog = wxString ( prelogUtf8.c_str(), wxConvUTF8, ( *it ).prelog.size() ); match = wxString ( matchUtf8.c_str(), wxConvUTF8, ( *it ).match.size() ); postlog = wxString ( postlogUtf8.c_str(), wxConvUTF8, ( *it ).postlog.size() ); replace = wxString ( replaceUtf8.c_str(), wxConvUTF8, ( *it ).replace.size() ); report = wxString ( reportUtf8.c_str(), wxConvUTF8, ( *it ).report.size() ); table->InsertItem ( i, matchNo, 0 ); table->SetItem ( i, 1, prelog ); table->SetItem ( i, 2, match ); table->SetItem ( i, 3, postlog ); table->SetItem ( i, 4, replace ); table->SetItem ( i, 5, report ); setIgnore ( i, ( *it ).tentative ); table->SetItemData ( i, i ); ++i; } wxString message; message.Printf ( wxPLURAL ( "%i error", "%i errors", i ), i ); status->SetStatusText ( message ); if ( i ) table->SetFocus(); }
GestureRecognizer::RecognizeFlag GestureRecognizerFlick::recognize(Gesture* ges, MotionAction action, int num, float xs[], float ys[]) { GestureRecognizer::RecognizeFlag retFlag = RecognizeFlag_Invaild; GestureFlick* flick = static_cast<GestureFlick*>(ges); if (!flick) return retFlag; GestureState state = flick->state(); if (num == 0) { return retFlag; } if (ignore()) { if (maybeGesture) { flick->clear(); } return retFlag; } switch (action) { case MotionAction_Down: { if (num == 1) { maybeGesture = true; flick->updateTrace(GesturePoint(xs[0], ys[0]), currentTime()); } } break; case MotionAction_Up: { if (maybeGesture) { flick->calcFlickInfo(); CCLOG("speed = %f ", flick->speed()); if (flick->speed() > S1) { flick->setPoint(GesturePoint(xs[0], ys[0])); flick->setState(GestureState_Triggered); retFlag = RecognizeFlag_Triggered; } else { flick->clear(); } } } break; case MotionAction_Pointer_Down: case MotionAction_Pointer_Up: { setIgnore(true); } break; case MotionAction_Move: { if (num == 1 && maybeGesture) { flick->updateTrace(GesturePoint(xs[0], ys[0]), currentTime()); } } break; default: break; } return retFlag; }