コード例 #1
0
void PageManager::changePage(const std::string &pageName)
{
    // close last page.
    auto page = getPage(pageName);
    if ( pageName == currentPageName_ || !page )
    {
        return;
    }
    currentPageName_ = pageName;
    auto newState = dynamic_cast<State<RootPage>*>( page );
    if ( stateMachineRef_ )
    {
        stateMachineRef_->changeState(newState);
    }

    // add page as child of MainScene's middle layer
    auto middleLayer = rootPage()->_middleLayer;
    if ( middleLayer )
    {
        middleLayer->removeAllChildren();
        middleLayer->addChild(page);
    }
    
    bool shouldShowTestBtn = ("MainPage" != currentPageName_);
    rootPage()->_preTestBtn ? 
        rootPage()->_preTestBtn->setVisible(shouldShowTestBtn) : void(0);
    rootPage()->_nextTestBtn ? 
        rootPage()->_nextTestBtn->setVisible(shouldShowTestBtn) : void(0);

}
コード例 #2
0
ファイル: BTree.cpp プロジェクト: EndlessCheng/mymymysql
 void BTree::trace(const Key& key, std::vector<int>* tr, bool& found, PageDB::Location& loc) {
     const Node* node;
     int currentPage = rootPage();
     while (true) {
         if (tr)
             tr->push_back(currentPage);
         PageDB::PageSession session = pgdb->GetSession(file, currentPage);
         node = reinterpret_cast<const Node*>(session.buf());
         if (node->size == 0) {
             found = false;
             break;
         }
         int idx = node->findIndex(key);
         auto locX = node->children[idx].loc;
         if (locX.Page != 0) {
             if (node->children[idx].less == key) {
                 found = true;
                 loc = locX;
                 break;
             } else {
                 found = false;
                 break;
             }
         } else {
             currentPage = locX.Offset;
         }
     }
 }
コード例 #3
0
ファイル: BTree.cpp プロジェクト: EndlessCheng/mymymysql
 void BTree::insertCore(Key key, std::vector<int>& trace, PageDB::Location loc) {
     Node *currentNode, *splitNode;
     int sp = trace.size() - 1;
     for(; sp > -1; sp--) {
         PageDB::PageWriteSession session1 = pgdb->GetWriteSession(file, trace[sp]);
         currentNode = reinterpret_cast<Node*>(session1.buf());
         if (currentNode->size != MinChild * 2) {
             currentNode->Insert(key, loc);
             break;
         }
         int newPage = file->newPage();
         PageDB::PageWriteSession session2 = pgdb->GetWriteSession(file, newPage);
         splitNode = reinterpret_cast<Node*>(session2.buf());
         currentNode->InsertAndSplit(key, loc, *splitNode);
         loc.Page = 0;
         loc.Offset = newPage;
         key = splitNode->children[0].less;
     }
     if (sp == -1) {
         int newPage = file->newPage();
         PageDB::PageWriteSession session = pgdb->GetWriteSession(file, newPage);
         currentNode = reinterpret_cast<Node*>(session.buf());
         currentNode->size = 2;
         currentNode->children[0].less = Key(INT_MIN, INT_MIN, INT_MIN);
         currentNode->children[0].loc = PageDB::Location(0, trace[0]);
         currentNode->children[1].less = key;
         currentNode->children[1].loc = loc;
         rootPage() = newPage;
         entrySession.flush();
     }
 }
コード例 #4
0
void PageManager::changeBackGround(const std::string &pic)
{
    auto backLlayer = rootPage()->_backLayer;
    if ( backLlayer )
    {
        backLlayer->removeAllChildren();
        if ( pic.empty() )
        {
            // empty pic name will delete the background.
            return;
        }
        auto background = CCSprite::create(pic.c_str());
        if ( !background )
        {
            // invalid pic name will delete the background.
            return;
        }

        auto size = background->getContentSize();
        auto winSize = CocosWindow::size();
        background->setScaleX(winSize.width / size.width);
        background->setScaleY(winSize.height / size.height);
        background->setPosition(CocosWindow::center());
        backLlayer->addChild(background);
    }
}
コード例 #5
0
ファイル: BTree.cpp プロジェクト: EndlessCheng/mymymysql
 void BTree::removeCore(Key key, std::vector<int>& trace) {
     Node *parent;
     PageDB::PageWriteSession parentSession = pgdb->GetWriteSession(file, trace.back());
     parent = reinterpret_cast<Node*>(parentSession.buf());
     int sp;
     int idx = parent->findIndex(key);
     for (sp = trace.size() - 1; sp > 0; sp--) {
         Node* child = parent;
         child->Remove(idx);
         if (child->size >= MinChild) {
             break;
         }
         PageDB::PageWriteSession childSession = std::move(parentSession);
         parentSession = pgdb->GetWriteSession(file, trace[sp - 1]);
         parent = reinterpret_cast<Node*>(parentSession.buf());
         idx = parent->findIndex(child->children[0].less);
         if (idx > 0) {
             //Left
             PageDB::PageWriteSession siblingSession = pgdb->GetWriteSession(file, parent->children[idx - 1].loc.Offset);
             Node* sibling = reinterpret_cast<Node*>(siblingSession.buf());
             if (sibling->size > MinChild) {
                 auto item = sibling->children[sibling->size - 1];
                 child->Insert(item.less, item.loc);
                 sibling->Remove(sibling->size - 1);
                 parent->children[idx].less = child->children[0].less;
                 break;
             }
             //Merge
             sibling->Merge(*child);
             childSession.Release();
             pgdb->RemovePage(file, trace[sp]);
         } else {
             //Right
             PageDB::PageWriteSession siblingSession = pgdb->GetWriteSession(file, parent->children[idx + 1].loc.Offset);
             Node* sibling = reinterpret_cast<Node*>(siblingSession.buf());
             if (sibling->size > MinChild) {
                 auto item = sibling->children[0];
                 child->Insert(item.less, item.loc);
                 sibling->Remove(0);
                 parent->children[idx + 1].less = sibling->children[0].less;
                 break;
             }
             //Merge
             child->Merge(*sibling);
             siblingSession.Release();
             pgdb->RemovePage(file, parent->children[idx + 1].loc.Offset);
             idx++;
         }
     }
     if (sp == 0) {
         parent->Remove(idx);
         if (parent->size == 1 && parent->children[0].loc.Page == 0) {
             rootPage() = parent->children[0].loc.Offset;
             parentSession.Release();
             entrySession.flush();
         }
     }
 }
コード例 #6
0
void PageManager::init()
{
    registerPage("RootPage", rootPage());
    registerPage("MainPage", MainPage::create());
    MessageCenter::getInstance()->registerHanlder(
        MessageType::kMessageTypeChangePage, this, -1);
    MessageCenter::getInstance()->registerHanlder(
        MessageType::kMessageTypeChangeBackground, this, -1);
}
コード例 #7
0
QWidget *VBoxSettingsToolBarSelector::rootPage (int aId) const
{
    QWidget *page = NULL;
    if (SelectorActionItem *item = findActionItem (aId))
    {
        if (item->parentId() > -1)
            page = rootPage (item->parentId());
        else if (item->page())
            page = item->page();
        else
            page = item->tabWidget();
    }
    return page;
}
コード例 #8
0
ファイル: BTree.cpp プロジェクト: EndlessCheng/mymymysql
 void BTree::initBTree() {
     magicNumber() = MagicNumber;
     int rtPage = file->newPage();
     int infoPage = file->newPage();
     file->eof.Page = infoPage;
     file->eof.Offset = sizeof(Information);
     file->writebackFileHeaderCore();
     rootPage() = rtPage;
     usedRecord() = 0;
     avalibleRecord() = 0;
     linkHeadPage() = infoPage;
     linkHeadOffset() = 0;
     PageDB::PageWriteSession s = pgdb->GetWriteSession(file, infoPage);
     Information* info = reinterpret_cast<Information*>(s.buf());
     info->next = info->prev = PageDB::Location(infoPage, 0);
     entrySession.flush();
 }
コード例 #9
0
PageManager::PageManager() : stateMachineRef_(rootPage()->_stateMachine)
{}