Exemplo n.º 1
0
void FrequencyMenu::onDownButton() {
    increaseFrequency();
    animationScheduler->update();
    showFrequency();
}
Exemplo n.º 2
0
// before 1st time use, must use HanZiCache ::init() !!!!!!!
HanZi16FontBitMap * HanZiCache :: getHanZiBMP ( const HanZi & hanzi )
{
    if ( ! HanZiCache::getIsInited()  )
   {
        HanZiCache::init();
   
   }
   
   
    HanZi16FontBitMap *temp_hanZiBMP_p = NULL;
    HanZi16CachedItem *tempCachedItem_P = NULL;
    bool found = false;
    unsigned int i = 0;
    for(i=0;i<currentSize;i++)
    {    
        tempCachedItem_P = getCachedItem( i );
        
        if( tempCachedItem_P == NULL )
        {   //impossible!!!!
            return NULL;
        }
        
        if ( tempCachedItem_P->hanZi == hanzi.ushort )
        {   //increase and resort
            increaseFrequency( tempCachedItem_P );
            //newIndex = HanZiCache ::sortCachedItem ( i );
            //tempCachedItem_P = getCachedItem( newIndex );
            temp_hanZiBMP_p = &(tempCachedItem_P->hanZi16BitMap);            
            found = true;
            break;
        }   
    }    
        
    if ( found )
    {
       return temp_hanZiBMP_p;
    }
     
    HanZi16FontBitMap *AddhanZiBMP  ; 
    //not found in the cache ???
    // let's add it to the cache !!!!!
    if( !found  )
    {
        if (  debugCache_cg )
        {
            printf( "not found in cache hanzi: %u \n", hanzi.ushort  );
        } 

       
        bool r;       
        unsigned short roomIndex;
        roomIndex = HanZiCache::getRoomForNewHanZi( ); 
        tempCachedItem_P = HanZiCache::getCachedItem ( roomIndex );
        tempCachedItem_P ->frequency = 0;
        tempCachedItem_P ->hanZi = hanzi.ushort;
        AddhanZiBMP = & tempCachedItem_P->hanZi16BitMap;
        r = PSP_CNFONTS16_16::drawHanZi16ToBMP( hanzi.ushort , *AddhanZiBMP  );
        if( !r )        
        {
            printf(" HanZiFontBitMap tempAddhanZiBMP size not enough for width*heigh!!\n");
        }
    }
    
       
    if (  debugCache_cg )
    {
        if( found )printf( "found in cache index %u \n", i );
    } 

    return AddhanZiBMP;
    
}