本文整理汇总了C++中CGUIControl::GetWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ CGUIControl::GetWidth方法的具体用法?C++ CGUIControl::GetWidth怎么用?C++ CGUIControl::GetWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGUIControl
的用法示例。
在下文中一共展示了CGUIControl::GetWidth方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetupPage
void CGUIDialogVisualisationSettings::SetupPage()
{
// cleanup first, if necessary
FreeControls();
m_pOriginalSpin = (CGUISpinControlEx*)GetControl(CONTROL_DEFAULT_SPIN);
m_pOriginalRadioButton = (CGUIRadioButtonControl *)GetControl(CONTROL_DEFAULT_RADIOBUTTON);
m_pOriginalSettingsButton = (CGUIButtonControl *)GetControl(CONTROL_DEFAULT_BUTTON);
if (!m_pOriginalSpin || !m_pOriginalRadioButton || !m_pOriginalSettingsButton)
return;
m_pOriginalSpin->SetVisible(false);
m_pOriginalRadioButton->SetVisible(false);
m_pOriginalSettingsButton->SetVisible(false);
// update our settings label
CStdString strSettings;
strSettings.Format("%s %s", g_infoManager.GetLabel(402).c_str(), g_localizeStrings.Get(5));
SET_CONTROL_LABEL(CONTROL_SETTINGS_LABEL, strSettings);
CGUIControlGroupList *group = (CGUIControlGroupList *)GetControl(CONTROL_GROUP_LIST);
#ifdef PRE_SKIN_VERSION_2_1_COMPATIBILITY
if (!group || group->GetControlType() != CGUIControl::GUICONTROL_GROUPLIST)
{
// our controls for layout...
CGUIControl *pArea = (CGUIControl *)GetControl(CONTROL_AREA);
const CGUIControl *pGap = GetControl(CONTROL_GAP);
if (!pArea || !pGap)
return;
Remove(CONTROL_AREA);
group = new CGUIControlGroupList(GetID(), CONTROL_GROUP_LIST, pArea->GetXPosition(), pArea->GetYPosition(),
pArea->GetWidth(), pArea->GetHeight(), pGap->GetHeight() - m_pOriginalSettingsButton->GetHeight(),
0, VERTICAL, false);
group->SetNavigation(CONTROL_GROUP_LIST, CONTROL_GROUP_LIST, CONTROL_GROUP_LIST, CONTROL_GROUP_LIST);
Insert(group, pGap);
pArea->FreeResources();
delete pArea;
SET_CONTROL_HIDDEN(CONTROL_PAGE);
}
#endif
if (!group)
return;
if (!m_pSettings || !m_pSettings->size())
{ // no settings available
SET_CONTROL_VISIBLE(CONTROL_NONE_AVAILABLE);
return;
}
else
{
SET_CONTROL_HIDDEN(CONTROL_NONE_AVAILABLE);
}
// run through and create our controls
for (unsigned int i = 0; i < m_pSettings->size(); i++)
{
VisSetting &setting = m_pSettings->at(i);
AddSetting(setting, group->GetWidth(), CONTROL_START + i);
}
UpdateSettings();
}
示例2: Load
bool CGUIDialog::Load(const CStdString& strFileName, bool bContainsPath)
{
m_renderOrder = 1;
if (!CGUIWindow::Load(strFileName, bContainsPath))
{
return false;
}
// Clip labels to extents
if (m_vecControls.size())
{
CGUIControl* pBase = m_vecControls[0];
for (ivecControls p = m_vecControls.begin() + 1; p != m_vecControls.end(); ++p)
{
if ((*p)->GetControlType() == CGUIControl::GUICONTROL_LABEL)
{
CGUILabelControl* pLabel = (CGUILabelControl*)(*p);
if (!pLabel->GetWidth())
{
float spacing = (pLabel->GetXPosition() - pBase->GetXPosition()) * 2;
pLabel->SetWidth(pBase->GetWidth() - spacing);
pLabel->SetTruncate(true);
}
}
}
}
return true;
}
示例3: GetWidth
float CGUIDialogContextMenu::GetWidth()
{
CGUIControl *pControl = (CGUIControl *)GetControl(BACKGROUND_IMAGE);
if (pControl)
return pControl->GetWidth();
else
return CGUIDialog::GetWidth();
}
示例4: EnlargeWidth
void CGUIListGroup::EnlargeWidth(float difference)
{
// Alters the width of the controls that have an ID of 1
for (iControls it = m_children.begin(); it != m_children.end(); it++)
{
CGUIControl *child = *it;
if (child->GetID() >= 1 && child->GetID() <= 14)
{
if (child->GetID() == 1) // label
{
child->SetWidth(child->GetWidth() + difference - 10);
child->SetVisible(child->GetWidth() > 10); ///
}
else
{
child->SetWidth(child->GetWidth() + difference);
}
}
}
SetInvalid();
}
示例5: LoadControl
void CGUIWindow::LoadControl(TiXmlElement* pControl, CGUIControlGroup *pGroup)
{
// get control type
CGUIControlFactory factory;
CRect rect(0, 0, (float)m_coordsRes.iWidth, (float)m_coordsRes.iHeight);
if (pGroup)
{
rect.x1 = pGroup->GetXPosition();
rect.y1 = pGroup->GetYPosition();
rect.x2 = rect.x1 + pGroup->GetWidth();
rect.y2 = rect.y1 + pGroup->GetHeight();
}
CGUIControl* pGUIControl = factory.Create(GetID(), rect, pControl);
if (pGUIControl)
{
float maxX = pGUIControl->GetXPosition() + pGUIControl->GetWidth();
if (maxX > m_width)
{
m_width = maxX;
}
float maxY = pGUIControl->GetYPosition() + pGUIControl->GetHeight();
if (maxY > m_height)
{
m_height = maxY;
}
// if we are in a group, add to the group, else add to our window
if (pGroup)
pGroup->AddControl(pGUIControl);
else
AddControl(pGUIControl);
// if the new control is a group, then add it's controls
if (pGUIControl->IsGroup())
{
TiXmlElement *pSubControl = pControl->FirstChildElement("control");
while (pSubControl)
{
LoadControl(pSubControl, (CGUIControlGroup *)pGUIControl);
pSubControl = pSubControl->NextSiblingElement("control");
}
}
}
}
示例6: LoadControl
void CGUIWindow::LoadControl(TiXmlElement* pControl, CGUIControlGroup *pGroup, const CRect &rect)
{
// get control type
CGUIControlFactory factory;
CGUIControl* pGUIControl = factory.Create(GetID(), rect, pControl);
if (pGUIControl)
{
float maxX = pGUIControl->GetXPosition() + pGUIControl->GetWidth();
if (maxX > m_width)
{
m_width = maxX;
}
float maxY = pGUIControl->GetYPosition() + pGUIControl->GetHeight();
if (maxY > m_height)
{
m_height = maxY;
}
// if we are in a group, add to the group, else add to our window
if (pGroup)
pGroup->AddControl(pGUIControl);
else
AddControl(pGUIControl);
// if the new control is a group, then add it's controls
if (pGUIControl->IsGroup())
{
CGUIControlGroup *grp = (CGUIControlGroup *)pGUIControl;
TiXmlElement *pSubControl = pControl->FirstChildElement("control");
CRect grpRect(grp->GetXPosition(), grp->GetYPosition(),
grp->GetXPosition() + grp->GetWidth(), grp->GetYPosition() + grp->GetHeight());
while (pSubControl)
{
LoadControl(pSubControl, grp, grpRect);
pSubControl = pSubControl->NextSiblingElement("control");
}
}
}
}
示例7: OnWindowLoaded
void CGUIDialog::OnWindowLoaded()
{
CGUIWindow::OnWindowLoaded();
// Clip labels to extents
if (m_children.size())
{
CGUIControl* pBase = m_children[0];
for (iControls p = m_children.begin() + 1; p != m_children.end(); ++p)
{
if ((*p)->GetControlType() == CGUIControl::GUICONTROL_LABEL)
{
CGUILabelControl* pLabel = (CGUILabelControl*)(*p);
if (!pLabel->GetWidth())
{
float spacing = (pLabel->GetXPosition() - pBase->GetXPosition()) * 2;
pLabel->SetWidth(pBase->GetWidth() - spacing);
}
}
}
}
}
示例8: SetupButtons
void CGUIDialogContextMenu::SetupButtons()
{
if (!m_buttons.size())
return;
// disable the template button control
CGUIButtonControl *pButtonTemplate = (CGUIButtonControl *)GetFirstFocusableControl(BUTTON_TEMPLATE);
if (!pButtonTemplate) pButtonTemplate = (CGUIButtonControl *)GetControl(BUTTON_TEMPLATE);
if (!pButtonTemplate)
return;
pButtonTemplate->SetVisible(false);
CGUIControlGroupList* pGroupList = NULL;
{
const CGUIControl* pControl = GetControl(GROUP_LIST);
if (pControl && pControl->GetControlType() == GUICONTROL_GROUPLIST)
pGroupList = (CGUIControlGroupList*)pControl;
}
// add our buttons
for (unsigned int i = 0; i < m_buttons.size(); i++)
{
CGUIButtonControl *pButton = new CGUIButtonControl(*pButtonTemplate);
if (pButton)
{ // set the button's ID and position
int id = BUTTON_START + i;
pButton->SetID(id);
pButton->SetVisible(true);
pButton->SetLabel(m_buttons[i].second);
if (pGroupList)
{
pButton->SetPosition(pButtonTemplate->GetXPosition(), pButtonTemplate->GetYPosition());
pGroupList->AddControl(pButton);
}
#if PRE_SKIN_VERSION_11_COMPATIBILITY
else
{
pButton->SetPosition(pButtonTemplate->GetXPosition(), i*(pButtonTemplate->GetHeight() + SPACE_BETWEEN_BUTTONS));
pButton->SetNavigation(id - 1, id + 1, id, id);
AddControl(pButton);
}
#endif
}
}
CGUIControl *pControl = NULL;
#if PRE_SKIN_VERSION_11_COMPATIBILITY
if (!pGroupList)
{
// if we don't have grouplist update the navigation of the first and last buttons
pControl = (CGUIControl *)GetControl(BUTTON_START);
if (pControl)
pControl->SetNavigation(BUTTON_END, pControl->GetControlIdDown(), pControl->GetControlIdLeft(), pControl->GetControlIdRight());
pControl = (CGUIControl *)GetControl(BUTTON_END);
if (pControl)
pControl->SetNavigation(pControl->GetControlIdUp(), BUTTON_START, pControl->GetControlIdLeft(), pControl->GetControlIdRight());
}
#endif
// fix up background images placement and size
pControl = (CGUIControl *)GetControl(BACKGROUND_IMAGE);
if (pControl)
{
// first set size of background image
if (pGroupList)
{
if (pGroupList->GetOrientation() == VERTICAL)
{
// keep gap between bottom edges of grouplist and background image
pControl->SetHeight(pControl->GetHeight() - pGroupList->Size() + pGroupList->GetHeight());
}
else
{
// keep gap between right edges of grouplist and background image
pControl->SetWidth(pControl->GetWidth() - pGroupList->Size() + pGroupList->GetWidth());
}
}
#if PRE_SKIN_VERSION_11_COMPATIBILITY
else
pControl->SetHeight(m_buttons.size() * (pButtonTemplate->GetHeight() + SPACE_BETWEEN_BUTTONS));
if (pGroupList && pGroupList->GetOrientation() == HORIZONTAL)
{
// if there is grouplist control with horizontal orientation - adjust width of top and bottom background
CGUIControl* pControl2 = (CGUIControl *)GetControl(BACKGROUND_TOP);
if (pControl2)
pControl2->SetWidth(pControl->GetWidth());
pControl2 = (CGUIControl *)GetControl(BACKGROUND_BOTTOM);
if (pControl2)
pControl2->SetWidth(pControl->GetWidth());
}
else
{
// adjust position of bottom background
CGUIControl* pControl2 = (CGUIControl *)GetControl(BACKGROUND_BOTTOM);
if (pControl2)
pControl2->SetPosition(pControl2->GetXPosition(), pControl->GetYPosition() + pControl->GetHeight());
}
#endif
//.........这里部分代码省略.........
示例9: UpdateFromControl
void CGUIWindowSettingsScreenCalibration::UpdateFromControl(int iControl)
{
std::string strStatus;
RESOLUTION_INFO info = g_graphicsContext.GetResInfo(m_Res[m_iCurRes]);
if (iControl == CONTROL_PIXEL_RATIO)
{
CGUIControl *pControl = GetControl(CONTROL_PIXEL_RATIO);
if (pControl)
{
float fWidth = (float)pControl->GetWidth();
float fHeight = (float)pControl->GetHeight();
info.fPixelRatio = fHeight / fWidth;
// recenter our control...
pControl->SetPosition((info.iWidth - pControl->GetWidth()) / 2,
(info.iHeight - pControl->GetHeight()) / 2);
strStatus = StringUtils::Format("%s (%5.3f)", g_localizeStrings.Get(275).c_str(), info.fPixelRatio);
SET_CONTROL_LABEL(CONTROL_LABEL_ROW2, 278);
}
}
else
{
const CGUIMoverControl *pControl = dynamic_cast<const CGUIMoverControl*>(GetControl(iControl));
if (pControl)
{
switch (iControl)
{
case CONTROL_TOP_LEFT:
{
info.Overscan.left = pControl->GetXLocation();
info.Overscan.top = pControl->GetYLocation();
strStatus = StringUtils::Format("%s (%i,%i)", g_localizeStrings.Get(272).c_str(), pControl->GetXLocation(), pControl->GetYLocation());
SET_CONTROL_LABEL(CONTROL_LABEL_ROW2, 276);
}
break;
case CONTROL_BOTTOM_RIGHT:
{
info.Overscan.right = pControl->GetXLocation();
info.Overscan.bottom = pControl->GetYLocation();
int iXOff1 = info.iWidth - pControl->GetXLocation();
int iYOff1 = info.iHeight - pControl->GetYLocation();
strStatus = StringUtils::Format("%s (%i,%i)", g_localizeStrings.Get(273).c_str(), iXOff1, iYOff1);
SET_CONTROL_LABEL(CONTROL_LABEL_ROW2, 276);
}
break;
case CONTROL_SUBTITLES:
{
info.iSubtitles = pControl->GetYLocation();
strStatus = StringUtils::Format("%s (%i)", g_localizeStrings.Get(274).c_str(), pControl->GetYLocation());
SET_CONTROL_LABEL(CONTROL_LABEL_ROW2, 277);
}
break;
}
}
}
g_graphicsContext.SetResInfo(m_Res[m_iCurRes], info);
// set the label control correctly
std::string strText;
if (g_Windowing.IsFullScreen())
strText = StringUtils::Format("%ix%[email protected]%.2f - %s | %s",
info.iScreenWidth,
info.iScreenHeight,
info.fRefreshRate,
g_localizeStrings.Get(244).c_str(),
strStatus.c_str());
else
strText = StringUtils::Format("%ix%i - %s | %s",
info.iScreenWidth,
info.iScreenHeight,
g_localizeStrings.Get(242).c_str(),
strStatus.c_str());
SET_CONTROL_LABEL(CONTROL_LABEL_ROW1, strText);
}
示例10: Window_GetControlById
//.........这里部分代码省略.........
break;
case CGUIControl::GUICONTROL_IMAGE:
pControl = (Control*)ControlImage_Type.tp_alloc(&ControlImage_Type, 0);
new(&((ControlImage*)pControl)->strFileName) string();
break;
case CGUIControl::GUICONTROL_PROGRESS:
pControl = (Control*)ControlProgress_Type.tp_alloc(&ControlProgress_Type, 0);
new(&((ControlProgress*)pControl)->strTextureLeft) string();
new(&((ControlProgress*)pControl)->strTextureMid) string();
new(&((ControlProgress*)pControl)->strTextureRight) string();
new(&((ControlProgress*)pControl)->strTextureBg) string();
new(&((ControlProgress*)pControl)->strTextureOverlay) string();
break;
case CGUIControl::GUICONTROL_SLIDER:
pControl = (Control*)ControlSlider_Type.tp_alloc(&ControlSlider_Type, 0);
new(&((ControlSlider*)pControl)->strTextureBack) string();
new(&((ControlSlider*)pControl)->strTexture) string();
new(&((ControlSlider*)pControl)->strTextureFoc) string();
break;
case CGUIControl::GUICONTAINER_LIST:
case CGUIControl::GUICONTAINER_WRAPLIST:
case CGUIControl::GUICONTAINER_FIXEDLIST:
case CGUIControl::GUICONTAINER_PANEL:
pControl = (Control*)ControlList_Type.tp_alloc(&ControlList_Type, 0);
new(&((ControlList*)pControl)->strFont) string();
new(&((ControlList*)pControl)->strTextureButton) string();
new(&((ControlList*)pControl)->strTextureButtonFocus) string();
new(&((ControlList*)pControl)->vecItems) std::vector<PYXBMC::ListItem*>();
// create a python spin control
((ControlList*)pControl)->pControlSpin = (ControlSpin*)ControlSpin_New();
break;
case CGUIControl::GUICONTROL_GROUP:
pControl = (Control*)ControlGroup_Type.tp_alloc(&ControlGroup_Type, 0);
break;
case CGUIControl::GUICONTROL_RADIO:
pControl = (Control*)ControlRadioButton_Type.tp_alloc(&ControlRadioButton_Type, 0);
new(&((ControlRadioButton*)pControl)->strFont) string();
new(&((ControlRadioButton*)pControl)->strText) string();
new(&((ControlRadioButton*)pControl)->strTextureFocus) string();
new(&((ControlRadioButton*)pControl)->strTextureNoFocus) string();
new(&((ControlRadioButton*)pControl)->strTextureRadioFocus) string();
new(&((ControlRadioButton*)pControl)->strTextureRadioNoFocus) string();
li = ((CGUIRadioButtonControl *)pGUIControl)->GetLabelInfo();
// note: conversion from infocolors -> plain colors here
((ControlRadioButton*)pControl)->disabledColor = li.disabledColor;
((ControlRadioButton*)pControl)->focusedColor = li.focusedColor;
((ControlRadioButton*)pControl)->textColor = li.textColor;
((ControlRadioButton*)pControl)->shadowColor = li.shadowColor;
if (li.font) ((ControlRadioButton*)pControl)->strFont = li.font->GetFontName();
((ControlRadioButton*)pControl)->align = li.align;
break;
case CGUIControl::GUICONTROL_EDIT:
pControl = (Control*)ControlEdit_Type.tp_alloc(&ControlEdit_Type, 0);
new(&((ControlEdit*)pControl)->strFont) string();
new(&((ControlEdit*)pControl)->strText) string();
new(&((ControlEdit*)pControl)->strTextureFocus) string();
new(&((ControlEdit*)pControl)->strTextureNoFocus) string();
li = ((CGUIEditControl *)pGUIControl)->GetLabelInfo();
// note: conversion from infocolors -> plain colors here
((ControlEdit*)pControl)->disabledColor = li.disabledColor;
((ControlEdit*)pControl)->textColor = li.textColor;
if (li.font) ((ControlEdit*)pControl)->strFont = li.font->GetFontName();
((ControlButton*)pControl)->align = li.align;
break;
default:
break;
}
if (!pControl)
{
// throw an exeption
PyErr_SetString(PyExc_Exception, "Unknown control type for python");
return NULL;
}
Py_INCREF(pControl);
// we have a valid control here, fill in all the 'Control' data
pControl->pGUIControl = pGUIControl;
pControl->iControlId = pGUIControl->GetID();
pControl->iParentId = self->iWindowId;
pControl->dwHeight = (int)pGUIControl->GetHeight();
pControl->dwWidth = (int)pGUIControl->GetWidth();
pControl->dwPosX = (int)pGUIControl->GetXPosition();
pControl->dwPosY = (int)pGUIControl->GetYPosition();
pControl->iControlUp = pGUIControl->GetControlIdUp();
pControl->iControlDown = pGUIControl->GetControlIdDown();
pControl->iControlLeft = pGUIControl->GetControlIdLeft();
pControl->iControlRight = pGUIControl->GetControlIdRight();
// It got this far so means the control isn't actually in the vector of controls
// so lets add it to save doing all that next time
self->vecControls.push_back(pControl);
// return the control with increased reference (+1)
return pControl;
}
示例11: GetControlById
//.........这里部分代码省略.........
((ControlButton*)pControl)->shadowColor = li.shadowColor;
if (li.font) ((ControlButton*)pControl)->strFont = li.font->GetFontName();
((ControlButton*)pControl)->align = li.align;
break;
case CGUIControl::GUICONTROL_CHECKMARK:
pControl = new ControlCheckMark();
li = ((CGUICheckMarkControl *)pGUIControl)->GetLabelInfo();
// note: conversion to plain colors from infocolors.
((ControlCheckMark*)pControl)->disabledColor = li.disabledColor;
//((ControlCheckMark*)pControl)->shadowColor = li.shadowColor;
((ControlCheckMark*)pControl)->textColor = li.textColor;
if (li.font) ((ControlCheckMark*)pControl)->strFont = li.font->GetFontName();
((ControlCheckMark*)pControl)->align = li.align;
break;
case CGUIControl::GUICONTROL_LABEL:
pControl = new ControlLabel();
break;
case CGUIControl::GUICONTROL_SPIN:
pControl = new ControlSpin();
break;
case CGUIControl::GUICONTROL_FADELABEL:
pControl = new ControlFadeLabel();
break;
case CGUIControl::GUICONTROL_TEXTBOX:
pControl = new ControlTextBox();
break;
case CGUIControl::GUICONTROL_IMAGE:
pControl = new ControlImage();
break;
case CGUIControl::GUICONTROL_PROGRESS:
pControl = new ControlProgress();
break;
case CGUIControl::GUICONTROL_SLIDER:
pControl = new ControlSlider();
break;
case CGUIControl::GUICONTAINER_LIST:
case CGUIControl::GUICONTAINER_WRAPLIST:
case CGUIControl::GUICONTAINER_FIXEDLIST:
case CGUIControl::GUICONTAINER_PANEL:
pControl = new ControlList();
// create a python spin control
((ControlList*)pControl)->pControlSpin = new ControlSpin();
break;
case CGUIControl::GUICONTROL_GROUP:
pControl = new ControlGroup();
break;
case CGUIControl::GUICONTROL_RADIO:
pControl = new ControlRadioButton();
li = ((CGUIRadioButtonControl *)pGUIControl)->GetLabelInfo();
// note: conversion from infocolors -> plain colors here
((ControlRadioButton*)pControl)->disabledColor = li.disabledColor;
((ControlRadioButton*)pControl)->focusedColor = li.focusedColor;
((ControlRadioButton*)pControl)->textColor = li.textColor;
((ControlRadioButton*)pControl)->shadowColor = li.shadowColor;
if (li.font) ((ControlRadioButton*)pControl)->strFont = li.font->GetFontName();
((ControlRadioButton*)pControl)->align = li.align;
break;
case CGUIControl::GUICONTROL_EDIT:
pControl = new ControlEdit();
li = ((CGUIEditControl *)pGUIControl)->GetLabelInfo();
// note: conversion from infocolors -> plain colors here
((ControlEdit*)pControl)->disabledColor = li.disabledColor;
((ControlEdit*)pControl)->textColor = li.textColor;
if (li.font) ((ControlEdit*)pControl)->strFont = li.font->GetFontName();
((ControlButton*)pControl)->align = li.align;
break;
default:
break;
}
if (!pControl)
// throw an exeption
throw WindowException("Unknown control type for python");
// we have a valid control here, fill in all the 'Control' data
pControl->pGUIControl = pGUIControl;
pControl->iControlId = pGUIControl->GetID();
pControl->iParentId = iWindowId;
pControl->dwHeight = (int)pGUIControl->GetHeight();
pControl->dwWidth = (int)pGUIControl->GetWidth();
pControl->dwPosX = (int)pGUIControl->GetXPosition();
pControl->dwPosY = (int)pGUIControl->GetYPosition();
pControl->iControlUp = pGUIControl->GetControlIdUp();
pControl->iControlDown = pGUIControl->GetControlIdDown();
pControl->iControlLeft = pGUIControl->GetControlIdLeft();
pControl->iControlRight = pGUIControl->GetControlIdRight();
// It got this far so means the control isn't actually in the vector of controls
// so lets add it to save doing all that next time
vecControls.push_back(AddonClass::Ref<Control>(pControl));
// return the control with increased reference (+1)
return pControl;
}