本文整理汇总了C++中CGUIDialogContextMenu::CenterWindow方法的典型用法代码示例。如果您正苦于以下问题:C++ CGUIDialogContextMenu::CenterWindow方法的具体用法?C++ CGUIDialogContextMenu::CenterWindow怎么用?C++ CGUIDialogContextMenu::CenterWindow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGUIDialogContextMenu
的用法示例。
在下文中一共展示了CGUIDialogContextMenu::CenterWindow方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SwitchMedia
void CGUIDialogContextMenu::SwitchMedia(const CStdString& strType, const CStdString& strPath)
{
// what should we display?
vector <CStdString> vecTypes;
if (!strType.Equals("music"))
vecTypes.push_back(g_localizeStrings.Get(2)); // My Music
if (!strType.Equals("video"))
vecTypes.push_back(g_localizeStrings.Get(3)); // My Videos
if (!strType.Equals("pictures"))
vecTypes.push_back(g_localizeStrings.Get(1)); // My Pictures
if (!strType.Equals("files"))
vecTypes.push_back(g_localizeStrings.Get(7)); // My Files
// something went wrong
if (vecTypes.size() != 3)
return;
// create menu
CGUIDialogContextMenu *pMenu = (CGUIDialogContextMenu *)m_gWindowManager.GetWindow(WINDOW_DIALOG_CONTEXT_MENU);
pMenu->Initialize();
// add buttons
int btn_Type[3];
for (int i=0; i<3; i++)
{
btn_Type[i] = pMenu->AddButton(vecTypes[i]);
}
// display menu
pMenu->CenterWindow();
pMenu->DoModal();
// check selection
int btn = pMenu->GetButton();
for (int i=0; i<3; i++)
{
if (btn == btn_Type[i])
{
// map back to correct window
int iWindow = WINDOW_INVALID;
if (vecTypes[i].Equals(g_localizeStrings.Get(2)))
iWindow = WINDOW_MUSIC_FILES;
else if (vecTypes[i].Equals(g_localizeStrings.Get(3)))
iWindow = WINDOW_VIDEO_FILES;
else if (vecTypes[i].Equals(g_localizeStrings.Get(1)))
iWindow = WINDOW_PICTURES;
else if (vecTypes[i].Equals(g_localizeStrings.Get(7)))
iWindow = WINDOW_FILES;
//m_gWindowManager.ActivateWindow(iWindow, strPath);
CUtil::ClearFileItemCache();
m_gWindowManager.ChangeActiveWindow(iWindow, strPath);
return;
}
}
return;
}
示例2: SelectPlayerDialog
EPLAYERCORES CPlayerCoreFactory::SelectPlayerDialog(VECPLAYERCORES &vecCores, float posX, float posY)
{
CGUIDialogContextMenu *pMenu = (CGUIDialogContextMenu *)m_gWindowManager.GetWindow(WINDOW_DIALOG_CONTEXT_MENU);
// Reset menu
pMenu->Initialize();
// Add all possible players
auto_aptr<int> btn_Cores(NULL);
if( vecCores.size() > 0 )
{
btn_Cores = new int[ vecCores.size() ];
btn_Cores[0] = 0;
CStdString strCaption;
//Add default player
strCaption = CPlayerCoreFactory::GetPlayerName(vecCores[0]);
strCaption += " (";
strCaption += g_localizeStrings.Get(13278);
strCaption += ")";
btn_Cores[0] = pMenu->AddButton(strCaption);
//Add all other players
for( unsigned int i = 1; i < vecCores.size(); i++ )
{
strCaption = CPlayerCoreFactory::GetPlayerName(vecCores[i]);
btn_Cores[i] = pMenu->AddButton(strCaption);
}
}
// Display menu
if (posX && posY)
pMenu->OffsetPosition(posX, posY);
else
pMenu->CenterWindow();
pMenu->DoModal();
//Check what player we selected
int btnid = pMenu->GetButton();
for( unsigned int i = 0; i < vecCores.size(); i++ )
{
if( btnid == btn_Cores[i] )
{
return vecCores[i];
}
}
return EPC_NONE;
}