// we swallow the draw frames mouse moves and process here void Editor::drawFrameMouseMovedEvent( QMouseEvent* e ){ POSITION mPos; transformPointToPosition(e->pos(), mPos, (mode == remove)); if ((mPos.x==currPos.x) && (mPos.y==currPos.y) && (mPos.e==currPos.e)) return; currPos = mPos; statusChanged(); switch(mode) { case insert: { POSITION next; next = currPos; if (next.e == 100) next.e = 0; else next.e += 1; drawCursor(next, canInsert(next)); break; } case remove: drawCursor(currPos, 1); break; case move: break; } }
bool PMInsertRuleSystem::canInsert( const PMObject* parentObject, const PMObject* object, const PMObject* after, const PMObjectList* objectsBetween ) { return canInsert( parentObject, object->type( ), after, objectsBetween ); }
// we swallow the draw frames mouse clicks and process here void Editor::drawFrameMousePressEvent( QMouseEvent* e ) { POSITION mPos; transformPointToPosition(e->pos(), mPos, (mode == remove)); switch (mode) { case remove: if (!theBoard.tileAbove(mPos) && mPos.e < BoardLayout::depth && theBoard.isTileAt(mPos) ) { theBoard.deleteTile(mPos); numTiles--; statusChanged(); drawFrameMouseMovedEvent(e); repaint(false); } break; case insert: { POSITION n = mPos; if (n.e == 100) n.e = 0; else n.e += 1; if (canInsert(n)) { theBoard.insertTile(n); numTiles++; statusChanged(); repaint(false); } } break; default: break; } }
int PMInsertRuleSystem::canInsert( const PMObject* parentObject, const PMObjectList& list, const PMObject* after ) { PMObjectListIterator it( list ); QStringList classes; for( ; it.current( ); ++it ) classes.append( it.current( )->type( ) ); return canInsert( parentObject, classes, after ); }
bool game::insertDisc(int column, int player){ column -= 1; for(int row = nrRows-1; row >= 0; row--) { if( canInsert(row, column, gameTable)) { gameTable[row][column] = (char)(((int)'0')+player); return true; } } return false; }
void Editor::drawFrameMousePressEvent( QMouseEvent* e ) { // we swallow the draw frames mouse clicks and process here POSITION mPos; transformPointToPosition(e->pos(), mPos, (mode == remove)); switch (mode) { case remove: if (!theBoard.tileAbove(mPos) && mPos.e < theBoard.m_depth && theBoard.isTileAt(mPos)) { theBoard.deleteTile(mPos); numTiles--; statusChanged(); drawFrameMouseMovedEvent(e); update(); } break; case insert: { POSITION n = mPos; if (n.e == 100) { n.e = 0; } else { n.e += 1; } if (canInsert(n)) { theBoard.insertTile(n); clean = false; numTiles++; statusChanged(); update(); } break; } default: break; } }
void Editor::drawFrameMouseMovedEvent(QMouseEvent *e) { // we swallow the draw frames mouse moves and process here POSITION mPos; transformPointToPosition(e->pos(), mPos, (mode == remove)); if ((mPos.x==currPos.x) && (mPos.y==currPos.y) && (mPos.e==currPos.e)) { return; } currPos = mPos; statusChanged(); switch(mode) { case insert: { POSITION next; next = currPos; if (next.e == 100) { next.e = 0; } else { next.e += 1; } drawCursor(next, canInsert(next)); break; } case remove: drawCursor(currPos, 1); break; case move: break; } }
PropertyTable::PropertyTable(VM& vm, unsigned initialCapacity, const PropertyTable& other) : JSCell(vm, vm.propertyTableStructure.get()) , m_indexSize(sizeForCapacity(initialCapacity)) , m_indexMask(m_indexSize - 1) , m_index(static_cast<unsigned*>(fastZeroedMalloc(dataSize()))) , m_keyCount(0) , m_deletedCount(0) { ASSERT(isPowerOf2(m_indexSize)); ASSERT(initialCapacity >= other.m_keyCount); const_iterator end = other.end(); for (const_iterator iter = other.begin(); iter != end; ++iter) { ASSERT(canInsert()); reinsert(*iter); iter->key->ref(); } // Copy the m_deletedOffsets vector. Vector<PropertyOffset>* otherDeletedOffsets = other.m_deletedOffsets.get(); if (otherDeletedOffsets) m_deletedOffsets = std::make_unique<Vector<PropertyOffset>>(*otherDeletedOffsets); }
int TTerminal::do_sputn( const char *s, int count ) { ushort screenLines = limit.y; for( ushort i = 0; i < count; i++ ) if( s[i] == '\n' ) screenLines++; while( !canInsert( count ) ) { queBack = nextLine( queBack ); screenLines--; } if( queFront + count >= bufSize ) { i = bufSize - queFront; memcpy( &buffer[queFront], s, i ); memcpy( buffer, &s[i], count - i ); queFront = count - i; } else { memcpy( &buffer[queFront], s, count ); queFront += count; } setLimit( limit.x, screenLines ); scrollTo( 0, screenLines + 1 ); i = prevLines( queFront, 1 ); if( i <= queFront ) i = queFront - i; else i = bufSize - (i - queFront); setCursor( i, screenLines - delta.y - 1 ); drawView(); return count; }
int PMInsertRuleSystem::canInsert( const PMObject* parentObject, const QStringList& list, const PMObject* after ) { if( list.size( ) == 1 ) { // more efficient if( canInsert( parentObject, list.first( ), after ) ) return 1; else return 0; } // find rules for target class QPtrList<PMRuleTargetClass> targetClassList; PMMetaObject* meta = parentObject->metaObject( ); for( ; meta; meta = meta->superClass( ) ) { PMRuleTargetClass* tc = m_rulesDict.find( meta->className( ) ); if( tc ) targetClassList.append( tc ); } if( targetClassList.isEmpty( ) ) return 0; // not rules found // count already inserted children QPtrListIterator<PMRuleTargetClass> tit( targetClassList ); for( ; tit.current( ); ++tit ) // ... for all target classes { QPtrListIterator<PMRule> rit = tit.current( )->rules( ); for( ; rit.current( ); ++rit ) // ... and all rules { rit.current( )->reset( ); bool afterInsertPoint = false; PMObject* o = parentObject->firstChild( ); if( !after ) afterInsertPoint = true; for( ; o; o = o->nextSibling( ) ) { rit.current( )->countChild( o->className( ), afterInsertPoint ); if( o == after ) afterInsertPoint = true; } } } int number = 0; QStringList::const_iterator oit; for( oit = list.begin( ); oit != list.end( ); ++oit ) { bool possible = false; for( tit.toFirst( ); tit.current( ) && !possible; ++tit ) { QPtrListIterator<PMRule> rit = tit.current( )->rules( ); for( ; rit.current( ) && !possible; ++rit ) { PMRule* rule = rit.current( ); if( rule->matches( *oit ) ) possible = rule->evaluate( parentObject ); } } if( possible ) { // object can be inserted, count it for( ; tit.current( ); ++tit ) { QPtrListIterator<PMRule> rit = tit.current( )->rules( ); for( ; rit.current( ); ++rit ) rit.current( )->countChild( *oit, false ); } number++; } } return number; }