void Element::checkSelfState(BP_Event& e) { //检测鼠标经过,按下等状态 //注意BP_MOUSEMOTION在mac下面有些问题,待查 if (e.type == BP_MOUSEMOTION) { if (inSide(e.motion.x, e.motion.y)) { state_ = Pass; } else { state_ = Normal; } } if ((e.type == BP_MOUSEBUTTONDOWN || e.type == BP_MOUSEBUTTONUP) && e.button.button == BP_BUTTON_LEFT) { if (inSide(e.button.x, e.button.y)) { state_ = Press; } else { state_ = Normal; } } if ((e.type == BP_KEYDOWN || e.type == BP_KEYUP) && (e.key.keysym.sym == BPK_RETURN || e.key.keysym.sym == BPK_SPACE)) { //按下键盘的空格或者回车时,将pass的按键改为press if (state_ == Pass) { state_ = Press; } } }
int dfs(vector< vector<int> >& matrix, vector< vector<int> >& longestPath, int x, int y, int n, int m, int len){ if(longestPath[x][y] != -1) return len + longestPath[x][y]; int dir[4][2] = { {1, 0}, {0, 1}, {-1, 0}, {0, -1} }; longestPath[x][y] = 1; for(int i = 0; i < 4; i++){ int xx = x + dir[i][0], yy = y + dir[i][1]; if(inSide(xx, yy, n, m) && matrix[x][y] < matrix[xx][yy]){ longestPath[x][y] = max(longestPath[x][y], dfs(matrix, longestPath, xx, yy, n, m, len + 1)); } } return len + longestPath[x][y]; }