⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 freeamptheme.cpp

📁 FreeAMP(MP3播放)程序源代码-用来研究MP3解码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
            
            bEnable = false;
            m_pWindow->ControlEnable(string("Volume"), true, bEnable);
            m_pWindow->ControlEnable(string("Balance"), true, bEnable);
            m_pWindow->ControlEnable(string("Mute"), true, bEnable);
            m_pWindow->ControlEnable(string("StereoIndicator"), true, bEnable);
            m_pWindow->ControlEnable(string("MonoIndicator"), true, bEnable);

            m_pWindow->ControlStringValue("SampleRate", true, oEmpty);
            m_pWindow->ControlStringValue("BitRate", true, oEmpty);

            bEnable = false;
            m_pWindow->ControlEnable(string("PlayIndicator"), true, bEnable);
            m_pWindow->ControlEnable(string("PauseIndicator"), true, bEnable);
            bEnable = true;
            m_pWindow->ControlEnable(string("StopIndicator"), true, bEnable);
         }
         else {
            bEnable = false;
            m_pWindow->ControlEnable(string("PlayIndicator"), true, bEnable);
            m_pWindow->ControlEnable(string("StopIndicator"), true, bEnable);
            bEnable = true;
            m_pWindow->ControlEnable(string("PauseIndicator"), true, bEnable);
         }
         
         break;
      }   
      case INFO_DoneOutputting:
      {
         m_iSeekPos = 0;
         m_iTotalSeconds = -1;
         m_iCurrentSeconds = -1;
         m_pWindow->ControlIntValue(string("Seek"), true, m_iSeekPos);
         UpdateTimeDisplay(m_iCurrentSeconds);
         
         break;
      }   
      case INFO_MediaInfo:
      {
         MediaInfoEvent *info = (MediaInfoEvent *) e;
         string oName("Title"), oText;
         char  *pFoo = strrchr(info->m_filename, '/');
         bool   bSet = true;

         if (m_oTitle.length() == 0)
         {
             pFoo = (pFoo ? ++pFoo : info->m_filename);
             m_oTitle = string(pFoo);
             m_pWindow->ControlStringValue(oName, true, m_oTitle);
             oText = string(BRANDING": ") + string(pFoo);
             m_pWindow->SetTitle(oText);
         }

		 // Enable/disable the seek slider
         m_iTotalSeconds = (int32) info->m_totalSeconds;
         bSet = (m_iTotalSeconds < 0) ? false : true;
         oName = string("Seek");
         m_pWindow->ControlEnable(oName, true, bSet);

         m_pContext->target->AcceptEvent(new Event(CMD_GetVolume));

         bSet = true;

         break;
      }
 
      case INFO_PlaylistItemsUpdated:
      {
         PlaylistItemsUpdatedEvent *pInfo = 
            (PlaylistItemsUpdatedEvent *)e;

         vector<PlaylistItem*>::const_iterator i = pInfo->Items()->begin();

         for(; i != pInfo->Items()->end(); i++)
         {
            if((*i) == m_pContext->plm->GetCurrentItem())
            {
                UpdateMetaData(*i);
                break;
            }
         }
         
         break;
      }
      case INFO_PlaylistCurrentItemInfo:
      {
         if (m_pContext->plm->GetCurrentIndex() != kInvalidIndex)
             UpdateMetaData(m_pContext->plm->GetCurrentItem());
         break;
      }

      case INFO_MusicCatalogTrackRemoved:
      {
         if ((int32)m_pContext->plm->GetCurrentIndex() < 0)
         {
             m_oTitle = szWelcomeMsg;
             m_pWindow->ControlStringValue("Title", true, m_oTitle);
             string title = BRANDING;
             m_pWindow->SetTitle(title);
         }    
         break;   
      }
      case INFO_StreamInfo:
      {
         char *szTitle;
         string oName("Title"), oText;

         StreamInfoEvent *pInfo = (StreamInfoEvent *) e;

         szTitle = new char[100];
         pInfo->GetTitle(szTitle, 100);
         m_oTitle = string(szTitle);
         m_pWindow->ControlStringValue(oName, true, m_oTitle);
         oText = string(BRANDING": ") + string(szTitle);
         m_pWindow->SetTitle(oText);
         delete [] szTitle;

         break;
      }
      case INFO_HeadlineText:
      {
         string oName("HeadlineInfo"), oText;

         HeadlineMessageEvent *pInfo = (HeadlineMessageEvent *) e;

         oText = string(pInfo->GetHeadlineMessage());
         m_oHeadlineUrl = string(pInfo->GetHeadlineURL());
         m_pWindow->ControlStringValue(oName, true, oText);
         oName = string("HeadlineStreamInfo");
         m_pWindow->ControlStringValue(oName, true, oText);

         break;
      }
      case INFO_BufferStatus:
      {
         StreamBufferEvent *info = (StreamBufferEvent *) e;
         char *szTemp;
         string oName("BufferInfo"), oText;

         if (info->IsBufferingUp())
         {
             string oControl("Info"), oDesc;
             char   szText[64];
             
             sprintf(szText, "Buffering up [%d%%]", 
                min((info->GetInputPercent()*3)/2, (int32)100));
             oDesc = string(szText);
             m_pWindow->ControlStringValue(oControl, true, oDesc);
             m_bBufferingUp = true;
         }   
         if (!info->IsBufferingUp() && m_bBufferingUp == true)
         {
             string oControl("Info"), oDesc("Playing stream...");
             m_pWindow->ControlStringValue(oControl, true, oDesc);
             m_bBufferingUp = false;
         }   

         szTemp = new char[100];
         sprintf(szTemp, "I: %3ld O: %3ld %c", 
                 (long int)info->GetInputPercent(),
                 (long int)info->GetOutputPercent(),
                 info->IsBufferingUp() ? '^' : ' ');
         oText = string(szTemp);
         
         if (m_bShowBuffers)
             oName = string("StreamInfo");

         m_pWindow->ControlStringValue(oName, true, oText);
         delete [] szTemp;

         break;
      }
         
      case INFO_MediaTimeInfo:
      {
         MediaTimeInfoEvent *info = (MediaTimeInfoEvent *) e;
         int                 iSeconds;
         string              oName("Time"), oText;

         iSeconds = (info->m_hours * 3600) + (info->m_minutes * 60) + 
                     info->m_seconds;
         if ((iSeconds == m_iCurrentSeconds && iSeconds > 0) || 
             m_bSeekInProgress)
             break;

         if (m_iFramesSinceSeek++ < 1)
             break;

         m_iCurrentSeconds = iSeconds;            
         UpdateTimeDisplay(m_iCurrentSeconds);

         if (m_iTotalSeconds > 0)
         {
            m_iSeekPos = (iSeconds * 100) / m_iTotalSeconds;
            oName = string("Seek");
            m_pWindow->ControlIntValue(oName, true, m_iSeekPos);
         }   

         break;
      }
      case INFO_MPEGInfo:
      {
         MpegInfoEvent *info = (MpegInfoEvent *) e;
         char          *text;

         text = new char[100];
         m_fSecondsPerFrame = info->GetSecondsPerFrame();
         if (info->GetBitRate() == 1411200)
              sprintf(text, "CD Audio");
         else if (info->GetBitRate() == 0)
              sprintf(text, "VBR %ldkHz %s", 
                   (long int)(info->GetSampleRate() / 1000), 
                   info->GetChannels() ? "Stereo" : "Mono");
         else
              sprintf(text, "%ldkbps %ldkHz %s", 
                   (long int)(info->GetBitRate() / 1000),
                   (long int)(info->GetSampleRate() / 1000), 
                   info->GetChannels() ? "Stereo" : "Mono");

         m_oStreamInfo = text;
         m_pWindow->ControlStringValue("StreamInfo", true, m_oStreamInfo);

         sprintf(text, "%d", info->GetBitRate() / 1000);    
         string tempstr = text;
         m_pWindow->ControlStringValue("BitRate", true, tempstr);
         
         sprintf(text, "%d", info->GetSampleRate() / 1000);
         tempstr = text;
         m_pWindow->ControlStringValue("SampleRate", true, tempstr);

         bool bEnable = (info->GetChannels() != 0);
         m_pWindow->ControlEnable(string("StereoIndicator"), true, bEnable);
         bEnable = !bEnable;
         m_pWindow->ControlEnable(string("MonoIndicator"), true, bEnable);
         delete [] text;
      
         break;
      }
      case INFO_VorbisInfo:
      {
         VorbisInfoEvent *info = (VorbisInfoEvent *) e;
         char            *text;

         text = new char[100];
         m_fSecondsPerFrame = info->GetSecondsPerFrame();
              sprintf(text, "%ldkbps %ldkHz %s Vorbis", 
                   (long int)(info->GetBitRate() / 1000),
                   (long int)(info->GetSampleRate() / 1000), 
                   info->GetChannels() ? "Stereo" : "Mono");

         m_oStreamInfo = text;
         m_pWindow->ControlStringValue("StreamInfo", true, m_oStreamInfo);

         sprintf(text, "%d", info->GetBitRate() / 1000);    
         string tempstr = text;
         m_pWindow->ControlStringValue("BitRate", true, tempstr);
         
         sprintf(text, "%d", info->GetSampleRate() / 1000);
         tempstr = text;
         m_pWindow->ControlStringValue("SampleRate", true, tempstr);

         bool bEnable = (info->GetChannels() != 0);
         m_pWindow->ControlEnable(string("StereoIndicator"), true, bEnable);
         bEnable = !bEnable;
         m_pWindow->ControlEnable(string("MonoIndicator"), true, bEnable);
         delete [] text;
      
         break;
      }

      case INFO_PlaylistRepeat:
      {
         PlaylistRepeatEvent *plre = (PlaylistRepeatEvent *) e;
         int iState;

         switch (plre->GetRepeatMode())
         {
             case kPlaylistMode_RepeatNone:
                iState = 0;
                break;
             case kPlaylistMode_RepeatOne:
                iState = 1;
                break;
             case kPlaylistMode_RepeatAll:
                iState = 2;
                break;
             default:
                break;
         }
         m_pWindow->ControlIntValue(string("Repeat"), true, iState);
         break;
      }
      case INFO_PlaylistShuffle:
      {
         PlaylistShuffleEvent *plse = (PlaylistShuffleEvent *) e;
         int iState;

         iState = plse->GetShuffleMode() ? 1 : 0;
         m_pWindow->ControlIntValue(string("Shuffle"), true, iState);
         break;
      }
      case INFO_VolumeInfo:
      {
         int iLeft, iRight;
         
         iLeft = ((VolumeEvent *) e)->GetLeftVolume();
         iRight = ((VolumeEvent *) e)->GetRightVolume();

         if (iLeft > iRight)
         {
             m_iVolume = iLeft;
             m_iBalance = iRight * 50 / iLeft ;
         }
         else
         {
             m_iVolume = iRight;
			 if (iRight == 0)
				 m_iBalance = 50;
			 else
                 m_iBalance = 50 + (50 - (iLeft * 50 / iRight)); 
         }

         m_pWindow->ControlIntValue(string("Volume"), true, m_iVolume);
         m_pWindow->ControlIntValue(string("Balance"), true, m_iBalance);

         if (iLeft > 0 || iRight > 0)
         {
   	       int iState = 0;
             m_pWindow->ControlIntValue(string("Mute"), false, iState);
         }

         char VolumeText[255];
         sprintf(VolumeText, "%d%%", m_iVolume);
         string oVol = string(VolumeText);
         m_pWindow->ControlStringValue(string("VolumeText"), true, oVol);

         break;
      }

      case INFO_PrefsChanged:
      {
		 /*
		  * Make sure that the theme has changed before we
		  * bother to reload it.
		  */
	     char    *szTemp;
		 uint32   iLen = 255;
		 string   oThemePath("");
		 struct  _stat buf;
	     bool bValue;

		 szTemp = new char[iLen];
		 m_pContext->prefs->GetPrefString(kThemePathPref, szTemp, &iLen);

	    if (strlen(szTemp) < 1) 
		    strcpy(szTemp, BRANDING_DEFAULT_THEME);
 
		if (_stat(szTemp, &buf) < 0)
		{
			// If the theme doesn't exist, let's try to prepend the install/theme dir
			char   *dir;
			uint32  len = _MAX_PATH;

			dir = new char[_MAX_PATH];
   
			m_pContext->prefs->GetPrefString(kInstallDirPref, dir, &len);
			oThemePath = string(dir);
#if defined(unix)
		    oThemePath += string(BRANDING_SHARE_PATH);
#endif
			oThemePath += string(DIR_MARKER_STR);    
			oThemePath += string("themes");
	        oThemePath += string(DIR_MARKER_STR);    

			delete [] dir;
		}
		oThemePath += szTemp;

		//
		// Perform the reload - if necessary.
		//
        if ( strcmp( oThemePath.c_str(), m_themeCache.c_str() ) != 0 )
		{
			ReloadTheme();
			m_themeCache = oThemePath;
		}

        m_pContext->prefs->GetPrefBoolean(kStayOnTopPref, &bValue);
        m_pWindow->SetStayOnTop(bValue);
        m_pContext->prefs->GetPrefBoolean(kLiveInTrayPref, &bValue);
        m_pWindow->SetLiveInToolbar(bValue);
         
      	break;
      }
      case CMD_ShowPreferences:
      {
          ShowPreferencesEvent* prefsEvent = (ShowPreferencesEvent*)e;
      	 ShowOptions(prefsEvent->GetDefaultPage());
      	 break;
      }

      case INFO_UnsignaturedTracksExist:
      {
          int    iState = 1;
 
          if (!m_pContext->aps->IsTurnedOn())
              iState = 0;

          m_sigState = kSigsPending;
          m_pWindow->ControlIntValue(string("SigIndicator"), true, iState);
      	 break;
      }

      case INFO_SignaturingStarted:
      {
          int    iState = 2;

          if (!m_pContext->aps->IsTurnedOn())
              iState = 0;

          m_sigState = kGeneratingSigs;
          m_pWindow->ControlIntValue(string("SigIndicator"), true, iState);

      	 break;
      }

      case INFO_SignaturingStopped:
      {
          int    iState;

          if (m_pContext->catalog->GetNumNeedingSigs() > 0)
          {
              m_sigState = kSigsPending;
              iState = 1;
          }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -