CGUIStaticItem::CGUIStaticItem(const TiXmlElement *item, int parentID) : CFileItem() { m_visState = false; assert(item); // check whether we're using the more verbose method... const TiXmlNode *click = item->FirstChild("onclick"); if (click && click->FirstChild()) { CGUIInfoLabel label, label2, thumb, icon; CGUIControlFactory::GetInfoLabel(item, "label", label, parentID); CGUIControlFactory::GetInfoLabel(item, "label2", label2, parentID); CGUIControlFactory::GetInfoLabel(item, "thumb", thumb, parentID); CGUIControlFactory::GetInfoLabel(item, "icon", icon, parentID); const char *id = item->Attribute("id"); CStdString condition; CGUIControlFactory::GetConditionalVisibility(item, condition); SetVisibleCondition(condition, parentID); CGUIControlFactory::GetActions(item, "onclick", m_clickActions); SetLabel(label.GetLabel(parentID)); SetLabel2(label2.GetLabel(parentID)); SetArt("thumb", thumb.GetLabel(parentID, true)); SetIconImage(icon.GetLabel(parentID, true)); if (!label.IsConstant()) m_info.push_back(make_pair(label, "label")); if (!label2.IsConstant()) m_info.push_back(make_pair(label2, "label2")); if (!thumb.IsConstant()) m_info.push_back(make_pair(thumb, "thumb")); if (!icon.IsConstant()) m_info.push_back(make_pair(icon, "icon")); m_iprogramCount = id ? atoi(id) : 0; // add any properties const TiXmlElement *property = item->FirstChildElement("property"); while (property) { CStdString name = property->Attribute("name"); CGUIInfoLabel prop; if (!name.empty() && CGUIControlFactory::GetInfoLabelFromElement(property, prop, parentID)) { SetProperty(name, prop.GetLabel(parentID, true).c_str()); if (!prop.IsConstant()) m_info.push_back(make_pair(prop, name)); } property = property->NextSiblingElement("property"); } } else { CStdString label, label2, thumb, icon; label = item->Attribute("label"); label = CGUIControlFactory::FilterLabel(label); label2 = item->Attribute("label2"); label2 = CGUIControlFactory::FilterLabel(label2); thumb = item->Attribute("thumb"); thumb = CGUIControlFactory::FilterLabel(thumb); icon = item->Attribute("icon"); icon = CGUIControlFactory::FilterLabel(icon); const char *id = item->Attribute("id"); SetLabel(CGUIInfoLabel::GetLabel(label, parentID)); SetPath(item->FirstChild()->Value()); SetLabel2(CGUIInfoLabel::GetLabel(label2, parentID)); SetArt("thumb", CGUIInfoLabel::GetLabel(thumb, parentID, true)); SetIconImage(CGUIInfoLabel::GetLabel(icon, parentID, true)); m_iprogramCount = id ? atoi(id) : 0; } }
CGUIEditControl::CGUIEditControl(int parentID, int controlID, float posX, float posY, float width, float height, const CTextureInfo &textureFocus, const CTextureInfo &textureNoFocus, const CLabelInfo& labelInfo, const std::string &text, const CLabelInfo& emptylabelInfo, const std::string &emptyText, int maxTextSize) : CGUIButtonControl(parentID, controlID, posX, posY, width, height, textureFocus, textureNoFocus, labelInfo), m_emptyLayout(emptylabelInfo.font, false) { ControlType = GUICONTROL_EDIT; m_textOffset = 0; m_textWidth = width; m_cursorPos = 0; m_cursorBlink = 0; m_inputHeading = 0; m_inputType = INPUT_TYPE_TEXT; m_smsLastKey = 0; m_smsKeyIndex = 0; m_highlighted = false; m_emptyLabelInfo = emptylabelInfo; CGUIInfoLabel info; info.SetLabel(emptyText,""); CStdStringW emptyTextW; g_charsetConverter.utf8ToW(info.GetLabel(GetParentID(), false), emptyTextW, false); m_emptyLayout.SetText(emptyTextW); m_maxTextSize = maxTextSize; std::string allowedText = GetAllowedText(text); SetLabel(allowedText); m_addToText2Counter = -1; }
bool CGUIControlFactory::GetInfoLabelFromElement(const TiXmlElement *element, CGUIInfoLabel &infoLabel, int parentID) { if (!element || !element->FirstChild()) return false; CStdString label = element->FirstChild()->Value(); if (label.IsEmpty() || label == "-") return false; CStdString fallback = element->Attribute("fallback"); if (StringUtils::IsNaturalNumber(label)) label = g_localizeStrings.Get(atoi(label)); else // we assume the skin xml's aren't encoded as UTF-8 g_charsetConverter.unknownToUTF8(label); if (StringUtils::IsNaturalNumber(fallback)) fallback = g_localizeStrings.Get(atoi(fallback)); else g_charsetConverter.unknownToUTF8(fallback); infoLabel.SetLabel(label, fallback, parentID); return true; }
CGUIControl* CGUIControlFactory::Create(int parentID, const CRect &rect, TiXmlElement* pControlNode, bool insideContainer) { // get the control type CStdString strType = GetType(pControlNode); CGUIControl::GUICONTROLTYPES type = TranslateControlType(strType); int id = 0; float posX = 0, posY = 0; float width = 0, height = 0; float minHeight = 0, minWidth = 0; CGUIAction leftActions, rightActions, upActions, downActions, backActions, nextActions, prevActions; int pageControl = 0; CGUIInfoColor colorDiffuse(0xFFFFFFFF); int defaultControl = 0; bool defaultAlways = false; CStdString strTmp; int singleInfo = 0; CStdString strLabel; int iUrlSet=0; CStdString toggleSelect; float spinWidth = 16; float spinHeight = 16; float spinPosX = 0, spinPosY = 0; float checkWidth = 0, checkHeight = 0; CStdString strSubType; int iType = SPIN_CONTROL_TYPE_TEXT; int iMin = 0; int iMax = 100; int iInterval = 1; float fMin = 0.0f; float fMax = 1.0f; float fInterval = 0.1f; bool bReverse = true; bool bReveal = false; CTextureInfo textureBackground, textureLeft, textureRight, textureMid, textureOverlay; CTextureInfo textureNib, textureNibFocus, textureBar, textureBarFocus; CTextureInfo textureLeftFocus, textureRightFocus; CTextureInfo textureUp, textureDown; CTextureInfo textureUpFocus, textureDownFocus; CTextureInfo texture, borderTexture; CGUIInfoLabel textureFile; CTextureInfo textureCheckMark, textureCheckMarkNF; CTextureInfo textureFocus, textureNoFocus; CTextureInfo textureAltFocus, textureAltNoFocus; CTextureInfo textureRadioOn, textureRadioOff; CTextureInfo imageNoFocus, imageFocus; CGUIInfoLabel texturePath; CRect borderSize; float sliderWidth = 150, sliderHeight = 16; CPoint offset; bool bHasPath = false; CGUIAction clickActions; CGUIAction altclickActions; CGUIAction focusActions; CGUIAction unfocusActions; CGUIAction textChangeActions; CStdString strTitle = ""; CStdString strRSSTags = ""; float buttonGap = 5; int iMovementRange = 0; CAspectRatio aspect; #ifdef PRE_SKIN_VERSION_9_10_COMPATIBILITY if (insideContainer) // default for inside containers is keep aspect.ratio = CAspectRatio::AR_KEEP; #endif CStdString allowHiddenFocus; CStdString enableCondition; vector<CAnimation> animations; bool bScrollLabel = false; bool bPulse = true; unsigned int timePerImage = 0; unsigned int fadeTime = 0; unsigned int timeToPauseAtEnd = 0; bool randomized = false; bool loop = true; bool wrapMultiLine = false; ORIENTATION orientation = VERTICAL; bool showOnePage = true; bool scrollOut = true; int preloadItems = 0; CLabelInfo labelInfo; CLabelInfo spinInfo; CGUIInfoColor textColor3; CGUIInfoColor headlineColor; float radioWidth = 0; float radioHeight = 0; float radioPosX = 0; float radioPosY = 0; CStdString altLabel; CStdString strLabel2; CStdString action; int focusPosition = 0; int scrollTime = 200; int timeBlocks = 36; int rulerUnit = 12; bool useControlCoords = false; bool renderFocusedLast = false; CRect hitRect; CPoint camera; bool hasCamera = false; bool resetOnLabelChange = true; bool bPassword = false; CStdString visibleCondition; ///////////////////////////////////////////////////////////////////////////// // Read control properties from XML // if (!pControlNode->Attribute("id", (int*) &id)) XMLUtils::GetInt(pControlNode, "id", (int&) id); // backward compatibility - not desired // TODO: Perhaps we should check here whether id is valid for focusable controls // such as buttons etc. For labels/fadelabels/images it does not matter XMLUtils::GetFloat(pControlNode, "posx", posX); XMLUtils::GetFloat(pControlNode, "posy", posY); // Convert these from relative coords CStdString pos; XMLUtils::GetString(pControlNode, "posx", pos); if (pos.Right(1) == "r") posX = rect.Width() - posX; XMLUtils::GetString(pControlNode, "posy", pos); if (pos.Right(1) == "r") posY = rect.Height() - posY; GetDimension(pControlNode, "width", width, minWidth); GetDimension(pControlNode, "height", height, minHeight); XMLUtils::GetFloat(pControlNode, "offsetx", offset.x); XMLUtils::GetFloat(pControlNode, "offsety", offset.y); // adjust width and height accordingly for groups. Groups should // take the width/height of the parent (adjusted for positioning) // if none is defined. if (type == CGUIControl::GUICONTROL_GROUP || type == CGUIControl::GUICONTROL_GROUPLIST) { if (!width) width = max(rect.x2 - posX, 0.0f); if (!height) height = max(rect.y2 - posY, 0.0f); } hitRect.SetRect(posX, posY, posX + width, posY + height); GetHitRect(pControlNode, hitRect); GetActions(pControlNode, "onup", upActions); GetActions(pControlNode, "ondown", downActions); GetActions(pControlNode, "onleft", leftActions); GetActions(pControlNode, "onright", rightActions); GetActions(pControlNode, "onnext", nextActions); GetActions(pControlNode, "onprev", prevActions); GetActions(pControlNode, "onback", backActions); if (XMLUtils::GetInt(pControlNode, "defaultcontrol", defaultControl)) { const char *always = pControlNode->FirstChildElement("defaultcontrol")->Attribute("always"); if (always && strnicmp(always, "true", 4) == 0) defaultAlways = true; } XMLUtils::GetInt(pControlNode, "pagecontrol", pageControl); GetInfoColor(pControlNode, "colordiffuse", colorDiffuse, parentID); GetConditionalVisibility(pControlNode, visibleCondition, allowHiddenFocus); XMLUtils::GetString(pControlNode, "enable", enableCondition); CRect animRect(posX, posY, posX + width, posY + height); GetAnimations(pControlNode, animRect, parentID, animations); GetInfoColor(pControlNode, "textcolor", labelInfo.textColor, parentID); GetInfoColor(pControlNode, "focusedcolor", labelInfo.focusedColor, parentID); GetInfoColor(pControlNode, "disabledcolor", labelInfo.disabledColor, parentID); GetInfoColor(pControlNode, "shadowcolor", labelInfo.shadowColor, parentID); GetInfoColor(pControlNode, "selectedcolor", labelInfo.selectedColor, parentID); XMLUtils::GetFloat(pControlNode, "textoffsetx", labelInfo.offsetX); XMLUtils::GetFloat(pControlNode, "textoffsety", labelInfo.offsetY); int angle = 0; // use the negative angle to compensate for our vertically flipped cartesian plane if (XMLUtils::GetInt(pControlNode, "angle", angle)) labelInfo.angle = (float)-angle; CStdString strFont; if (XMLUtils::GetString(pControlNode, "font", strFont)) labelInfo.font = g_fontManager.GetFont(strFont); GetAlignment(pControlNode, "align", labelInfo.align); uint32_t alignY = 0; if (GetAlignmentY(pControlNode, "aligny", alignY)) labelInfo.align |= alignY; if (XMLUtils::GetFloat(pControlNode, "textwidth", labelInfo.width)) labelInfo.align |= XBFONT_TRUNCATED; GetActions(pControlNode, "onclick", clickActions); GetActions(pControlNode, "ontextchange", textChangeActions); GetActions(pControlNode, "onfocus", focusActions); GetActions(pControlNode, "onunfocus", unfocusActions); focusActions.m_sendThreadMessages = unfocusActions.m_sendThreadMessages = true; GetActions(pControlNode, "altclick", altclickActions); CStdString infoString; if (XMLUtils::GetString(pControlNode, "info", infoString)) singleInfo = g_infoManager.TranslateString(infoString); GetTexture(pControlNode, "texturefocus", textureFocus); GetTexture(pControlNode, "texturenofocus", textureNoFocus); GetTexture(pControlNode, "alttexturefocus", textureAltFocus); GetTexture(pControlNode, "alttexturenofocus", textureAltNoFocus); XMLUtils::GetString(pControlNode, "usealttexture", toggleSelect); XMLUtils::GetString(pControlNode, "selected", toggleSelect); XMLUtils::GetBoolean(pControlNode, "haspath", bHasPath); GetTexture(pControlNode, "textureup", textureUp); GetTexture(pControlNode, "texturedown", textureDown); GetTexture(pControlNode, "textureupfocus", textureUpFocus); GetTexture(pControlNode, "texturedownfocus", textureDownFocus); GetTexture(pControlNode, "textureleft", textureLeft); GetTexture(pControlNode, "textureright", textureRight); GetTexture(pControlNode, "textureleftfocus", textureLeftFocus); GetTexture(pControlNode, "texturerightfocus", textureRightFocus); GetInfoColor(pControlNode, "spincolor", spinInfo.textColor, parentID); if (XMLUtils::GetString(pControlNode, "spinfont", strFont)) spinInfo.font = g_fontManager.GetFont(strFont); if (!spinInfo.font) spinInfo.font = labelInfo.font; XMLUtils::GetFloat(pControlNode, "spinwidth", spinWidth); XMLUtils::GetFloat(pControlNode, "spinheight", spinHeight); XMLUtils::GetFloat(pControlNode, "spinposx", spinPosX); XMLUtils::GetFloat(pControlNode, "spinposy", spinPosY); XMLUtils::GetFloat(pControlNode, "markwidth", checkWidth); XMLUtils::GetFloat(pControlNode, "markheight", checkHeight); XMLUtils::GetFloat(pControlNode, "sliderwidth", sliderWidth); XMLUtils::GetFloat(pControlNode, "sliderheight", sliderHeight); GetTexture(pControlNode, "texturecheckmark", textureCheckMark); GetTexture(pControlNode, "texturecheckmarknofocus", textureCheckMarkNF); GetTexture(pControlNode, "textureradiofocus", textureRadioOn); // backward compatibility GetTexture(pControlNode, "textureradionofocus", textureRadioOff); GetTexture(pControlNode, "textureradioon", textureRadioOn); GetTexture(pControlNode, "textureradiooff", textureRadioOff); GetTexture(pControlNode, "texturesliderbackground", textureBackground); GetTexture(pControlNode, "texturesliderbar", textureBar); GetTexture(pControlNode, "texturesliderbarfocus", textureBarFocus); GetTexture(pControlNode, "textureslidernib", textureNib); GetTexture(pControlNode, "textureslidernibfocus", textureNibFocus); XMLUtils::GetString(pControlNode, "title", strTitle); XMLUtils::GetString(pControlNode, "tagset", strRSSTags); GetInfoColor(pControlNode, "headlinecolor", headlineColor, parentID); GetInfoColor(pControlNode, "titlecolor", textColor3, parentID); if (XMLUtils::GetString(pControlNode, "subtype", strSubType)) { strSubType.ToLower(); if ( strSubType == "int") iType = SPIN_CONTROL_TYPE_INT; else if ( strSubType == "page") iType = SPIN_CONTROL_TYPE_PAGE; else if ( strSubType == "float") iType = SPIN_CONTROL_TYPE_FLOAT; else iType = SPIN_CONTROL_TYPE_TEXT; } if (!GetIntRange(pControlNode, "range", iMin, iMax, iInterval)) { GetFloatRange(pControlNode, "range", fMin, fMax, fInterval); } XMLUtils::GetBoolean(pControlNode, "reverse", bReverse); XMLUtils::GetBoolean(pControlNode, "reveal", bReveal); GetTexture(pControlNode, "texturebg", textureBackground); GetTexture(pControlNode, "lefttexture", textureLeft); GetTexture(pControlNode, "midtexture", textureMid); GetTexture(pControlNode, "righttexture", textureRight); GetTexture(pControlNode, "overlaytexture", textureOverlay); // the <texture> tag can be overridden by the <info> tag GetInfoTexture(pControlNode, "texture", texture, textureFile, parentID); #ifdef PRE_SKIN_VERSION_9_10_COMPATIBILITY if (type == CGUIControl::GUICONTROL_IMAGE && insideContainer && textureFile.IsConstant()) aspect.ratio = CAspectRatio::AR_STRETCH; #endif GetTexture(pControlNode, "bordertexture", borderTexture); GetTexture(pControlNode, "imagefolder", imageNoFocus); GetTexture(pControlNode, "imagefolderfocus", imageFocus); // fade label can have a whole bunch, but most just have one vector<CGUIInfoLabel> infoLabels; GetInfoLabels(pControlNode, "label", infoLabels, parentID); GetString(pControlNode, "label", strLabel); GetString(pControlNode, "altlabel", altLabel); GetString(pControlNode, "label2", strLabel2); XMLUtils::GetBoolean(pControlNode, "wrapmultiline", wrapMultiLine); XMLUtils::GetInt(pControlNode,"urlset",iUrlSet); if ( XMLUtils::GetString(pControlNode, "orientation", strTmp) ) { if (strTmp.ToLower() == "horizontal") orientation = HORIZONTAL; } XMLUtils::GetFloat(pControlNode, "itemgap", buttonGap); XMLUtils::GetInt(pControlNode, "movement", iMovementRange); GetAspectRatio(pControlNode, "aspectratio", aspect); XMLUtils::GetBoolean(pControlNode, "scroll", bScrollLabel); XMLUtils::GetBoolean(pControlNode,"pulseonselect", bPulse); XMLUtils::GetInt(pControlNode, "timeblocks", timeBlocks); XMLUtils::GetInt(pControlNode, "rulerunit", rulerUnit); GetInfoTexture(pControlNode, "imagepath", texture, texturePath, parentID); XMLUtils::GetUInt(pControlNode,"timeperimage", timePerImage); XMLUtils::GetUInt(pControlNode,"fadetime", fadeTime); XMLUtils::GetUInt(pControlNode,"pauseatend", timeToPauseAtEnd); XMLUtils::GetBoolean(pControlNode, "randomize", randomized); XMLUtils::GetBoolean(pControlNode, "loop", loop); XMLUtils::GetBoolean(pControlNode, "scrollout", scrollOut); XMLUtils::GetFloat(pControlNode, "radiowidth", radioWidth); XMLUtils::GetFloat(pControlNode, "radioheight", radioHeight); XMLUtils::GetFloat(pControlNode, "radioposx", radioPosX); XMLUtils::GetFloat(pControlNode, "radioposy", radioPosY); CStdString borderStr; if (XMLUtils::GetString(pControlNode, "bordersize", borderStr)) GetRectFromString(borderStr, borderSize); XMLUtils::GetBoolean(pControlNode, "showonepage", showOnePage); XMLUtils::GetInt(pControlNode, "focusposition", focusPosition); XMLUtils::GetInt(pControlNode, "scrolltime", scrollTime); XMLUtils::GetInt(pControlNode, "preloaditems", preloadItems, 0, 2); XMLUtils::GetBoolean(pControlNode, "usecontrolcoords", useControlCoords); XMLUtils::GetBoolean(pControlNode, "renderfocusedlast", renderFocusedLast); XMLUtils::GetBoolean(pControlNode, "resetonlabelchange", resetOnLabelChange); XMLUtils::GetBoolean(pControlNode, "password", bPassword); // view type VIEW_TYPE viewType = VIEW_TYPE_NONE; CStdString viewLabel; if (type == CGUIControl::GUICONTAINER_PANEL) { viewType = VIEW_TYPE_ICON; viewLabel = g_localizeStrings.Get(536); } else if (type == CGUIControl::GUICONTAINER_LIST) { viewType = VIEW_TYPE_LIST; viewLabel = g_localizeStrings.Get(535); } else { viewType = VIEW_TYPE_WRAP; viewLabel = g_localizeStrings.Get(541); } TiXmlElement *itemElement = pControlNode->FirstChildElement("viewtype"); if (itemElement && itemElement->FirstChild()) { CStdString type = itemElement->FirstChild()->Value(); if (type == "list") viewType = VIEW_TYPE_LIST; else if (type == "icon") viewType = VIEW_TYPE_ICON; else if (type == "biglist") viewType = VIEW_TYPE_BIG_LIST; else if (type == "bigicon") viewType = VIEW_TYPE_BIG_ICON; else if (type == "wide") viewType = VIEW_TYPE_WIDE; else if (type == "bigwide") viewType = VIEW_TYPE_BIG_WIDE; else if (type == "wrap") viewType = VIEW_TYPE_WRAP; else if (type == "bigwrap") viewType = VIEW_TYPE_BIG_WRAP; else if (type == "info") viewType = VIEW_TYPE_INFO; else if (type == "biginfo") viewType = VIEW_TYPE_BIG_INFO; const char *label = itemElement->Attribute("label"); if (label) viewLabel = CGUIInfoLabel::GetLabel(FilterLabel(label)); } TiXmlElement *cam = pControlNode->FirstChildElement("camera"); if (cam) { hasCamera = true; cam->QueryFloatAttribute("x", &camera.x); cam->QueryFloatAttribute("y", &camera.y); } XMLUtils::GetInt(pControlNode, "scrollspeed", labelInfo.scrollSpeed); spinInfo.scrollSpeed = labelInfo.scrollSpeed; GetString(pControlNode, "scrollsuffix", labelInfo.scrollSuffix); spinInfo.scrollSuffix = labelInfo.scrollSuffix; XMLUtils::GetString(pControlNode, "action", action); ///////////////////////////////////////////////////////////////////////////// // Instantiate a new control using the properties gathered above // CGUIControl *control = NULL; if (type == CGUIControl::GUICONTROL_GROUP) { if (insideContainer) { control = new CGUIListGroup(parentID, id, posX, posY, width, height); } else { control = new CGUIControlGroup( parentID, id, posX, posY, width, height); ((CGUIControlGroup *)control)->SetDefaultControl(defaultControl, defaultAlways); ((CGUIControlGroup *)control)->SetRenderFocusedLast(renderFocusedLast); } } else if (type == CGUIControl::GUICONTROL_GROUPLIST) { CScroller scroller; GetScroller(pControlNode, "scrolltime", scroller); control = new CGUIControlGroupList( parentID, id, posX, posY, width, height, buttonGap, pageControl, orientation, useControlCoords, labelInfo.align, scroller); ((CGUIControlGroup *)control)->SetRenderFocusedLast(renderFocusedLast); ((CGUIControlGroupList *)control)->SetMinSize(minWidth, minHeight); } else if (type == CGUIControl::GUICONTROL_LABEL) { const CGUIInfoLabel &content = (infoLabels.size()) ? infoLabels[0] : CGUIInfoLabel(""); if (insideContainer) { // inside lists we use CGUIListLabel control = new CGUIListLabel(parentID, id, posX, posY, width, height, labelInfo, content, bScrollLabel); } else { control = new CGUILabelControl( parentID, id, posX, posY, width, height, labelInfo, wrapMultiLine, bHasPath); ((CGUILabelControl *)control)->SetInfo(content); ((CGUILabelControl *)control)->SetWidthControl(minWidth, bScrollLabel); } } else if (type == CGUIControl::GUICONTROL_EDIT) { control = new CGUIEditControl( parentID, id, posX, posY, width, height, textureFocus, textureNoFocus, labelInfo, strLabel); CGUIInfoLabel hint_text; GetInfoLabel(pControlNode, "hinttext", hint_text, parentID); ((CGUIEditControl *) control)->SetHint(hint_text); if (bPassword) ((CGUIEditControl *) control)->SetInputType(CGUIEditControl::INPUT_TYPE_PASSWORD, 0); ((CGUIEditControl *) control)->SetTextChangeActions(textChangeActions); } else if (type == CGUIControl::GUICONTROL_VIDEO) { control = new CGUIVideoControl( parentID, id, posX, posY, width, height); } else if (type == CGUIControl::GUICONTROL_FADELABEL) { control = new CGUIFadeLabelControl( parentID, id, posX, posY, width, height, labelInfo, scrollOut, timeToPauseAtEnd, resetOnLabelChange); ((CGUIFadeLabelControl *)control)->SetInfo(infoLabels); } else if (type == CGUIControl::GUICONTROL_RSS) { control = new CGUIRSSControl( parentID, id, posX, posY, width, height, labelInfo, textColor3, headlineColor, strRSSTags); RssUrls::const_iterator iter = CRssManager::Get().GetUrls().find(iUrlSet); if (iter != CRssManager::Get().GetUrls().end()) ((CGUIRSSControl *)control)->SetUrlSet(iUrlSet); } else if (type == CGUIControl::GUICONTROL_BUTTON) { control = new CGUIButtonControl( parentID, id, posX, posY, width, height, textureFocus, textureNoFocus, labelInfo); ((CGUIButtonControl *)control)->SetLabel(strLabel); ((CGUIButtonControl *)control)->SetLabel2(strLabel2); ((CGUIButtonControl *)control)->SetClickActions(clickActions); ((CGUIButtonControl *)control)->SetFocusActions(focusActions); ((CGUIButtonControl *)control)->SetUnFocusActions(unfocusActions); } else if (type == CGUIControl::GUICONTROL_TOGGLEBUTTON) { control = new CGUIToggleButtonControl( parentID, id, posX, posY, width, height, textureFocus, textureNoFocus, textureAltFocus, textureAltNoFocus, labelInfo); ((CGUIToggleButtonControl *)control)->SetLabel(strLabel); ((CGUIToggleButtonControl *)control)->SetAltLabel(altLabel); ((CGUIToggleButtonControl *)control)->SetClickActions(clickActions); ((CGUIToggleButtonControl *)control)->SetAltClickActions(altclickActions); ((CGUIToggleButtonControl *)control)->SetFocusActions(focusActions); ((CGUIToggleButtonControl *)control)->SetUnFocusActions(unfocusActions); ((CGUIToggleButtonControl *)control)->SetToggleSelect(toggleSelect); } else if (type == CGUIControl::GUICONTROL_CHECKMARK) { control = new CGUICheckMarkControl( parentID, id, posX, posY, width, height, textureCheckMark, textureCheckMarkNF, checkWidth, checkHeight, labelInfo); ((CGUICheckMarkControl *)control)->SetLabel(strLabel); } else if (type == CGUIControl::GUICONTROL_RADIO) { control = new CGUIRadioButtonControl( parentID, id, posX, posY, width, height, textureFocus, textureNoFocus, labelInfo, textureRadioOn, textureRadioOff); ((CGUIRadioButtonControl *)control)->SetLabel(strLabel); ((CGUIRadioButtonControl *)control)->SetRadioDimensions(radioPosX, radioPosY, radioWidth, radioHeight); ((CGUIRadioButtonControl *)control)->SetToggleSelect(toggleSelect); ((CGUIRadioButtonControl *)control)->SetClickActions(clickActions); ((CGUIRadioButtonControl *)control)->SetFocusActions(focusActions); ((CGUIRadioButtonControl *)control)->SetUnFocusActions(unfocusActions); } else if (type == CGUIControl::GUICONTROL_MULTISELECT) { CGUIInfoLabel label; if (infoLabels.size()) label = infoLabels[0]; control = new CGUIMultiSelectTextControl( parentID, id, posX, posY, width, height, textureFocus, textureNoFocus, labelInfo, label); } else if (type == CGUIControl::GUICONTROL_SPIN) { control = new CGUISpinControl( parentID, id, posX, posY, width, height, textureUp, textureDown, textureUpFocus, textureDownFocus, labelInfo, iType); ((CGUISpinControl *)control)->SetReverse(bReverse); if (iType == SPIN_CONTROL_TYPE_INT) { ((CGUISpinControl *)control)->SetRange(iMin, iMax); } else if (iType == SPIN_CONTROL_TYPE_PAGE) { ((CGUISpinControl *)control)->SetRange(iMin, iMax); ((CGUISpinControl *)control)->SetShowRange(true); ((CGUISpinControl *)control)->SetReverse(false); ((CGUISpinControl *)control)->SetShowOnePage(showOnePage); } else if (iType == SPIN_CONTROL_TYPE_FLOAT) { ((CGUISpinControl *)control)->SetFloatRange(fMin, fMax); ((CGUISpinControl *)control)->SetFloatInterval(fInterval); } } else if (type == CGUIControl::GUICONTROL_SLIDER) { control = new CGUISliderControl( parentID, id, posX, posY, width, height, textureBar, textureNib, textureNibFocus, SPIN_CONTROL_TYPE_TEXT); ((CGUISliderControl *)control)->SetInfo(singleInfo); ((CGUISliderControl *)control)->SetAction(action); } else if (type == CGUIControl::GUICONTROL_SETTINGS_SLIDER) { control = new CGUISettingsSliderControl( parentID, id, posX, posY, width, height, sliderWidth, sliderHeight, textureFocus, textureNoFocus, textureBar, textureNib, textureNibFocus, labelInfo, SPIN_CONTROL_TYPE_TEXT); ((CGUISettingsSliderControl *)control)->SetText(strLabel); ((CGUISettingsSliderControl *)control)->SetInfo(singleInfo); } else if (type == CGUIControl::GUICONTROL_SCROLLBAR) { control = new CGUIScrollBar( parentID, id, posX, posY, width, height, textureBackground, textureBar, textureBarFocus, textureNib, textureNibFocus, orientation, showOnePage); } else if (type == CGUIControl::GUICONTROL_PROGRESS) { control = new CGUIProgressControl( parentID, id, posX, posY, width, height, textureBackground, textureLeft, textureMid, textureRight, textureOverlay, bReveal); ((CGUIProgressControl *)control)->SetInfo(singleInfo); } else if (type == CGUIControl::GUICONTROL_IMAGE) { if (strType == "largeimage") texture.useLarge = true; // use a bordered texture if we have <bordersize> or <bordertexture> specified. if (borderTexture.filename.IsEmpty() && borderStr.IsEmpty()) control = new CGUIImage( parentID, id, posX, posY, width, height, texture); else control = new CGUIBorderedImage( parentID, id, posX, posY, width, height, texture, borderTexture, borderSize); ((CGUIImage *)control)->SetInfo(textureFile); ((CGUIImage *)control)->SetAspectRatio(aspect); ((CGUIImage *)control)->SetCrossFade(fadeTime); } else if (type == CGUIControl::GUICONTROL_MULTI_IMAGE) { control = new CGUIMultiImage( parentID, id, posX, posY, width, height, texture, timePerImage, fadeTime, randomized, loop, timeToPauseAtEnd); ((CGUIMultiImage *)control)->SetInfo(texturePath); ((CGUIMultiImage *)control)->SetAspectRatio(aspect); } else if (type == CGUIControl::GUICONTAINER_LIST) { CScroller scroller; GetScroller(pControlNode, "scrolltime", scroller); control = new CGUIListContainer(parentID, id, posX, posY, width, height, orientation, scroller, preloadItems); ((CGUIListContainer *)control)->LoadLayout(pControlNode); ((CGUIListContainer *)control)->LoadContent(pControlNode); ((CGUIListContainer *)control)->SetDefaultControl(defaultControl, defaultAlways); ((CGUIListContainer *)control)->SetType(viewType, viewLabel); ((CGUIListContainer *)control)->SetPageControl(pageControl); ((CGUIListContainer *)control)->SetRenderOffset(offset); } else if (type == CGUIControl::GUICONTAINER_WRAPLIST) { CScroller scroller; GetScroller(pControlNode, "scrolltime", scroller); control = new CGUIWrappingListContainer(parentID, id, posX, posY, width, height, orientation, scroller, preloadItems, focusPosition); ((CGUIWrappingListContainer *)control)->LoadLayout(pControlNode); ((CGUIWrappingListContainer *)control)->LoadContent(pControlNode); ((CGUIWrappingListContainer *)control)->SetDefaultControl(defaultControl, defaultAlways); ((CGUIWrappingListContainer *)control)->SetType(viewType, viewLabel); ((CGUIWrappingListContainer *)control)->SetPageControl(pageControl); ((CGUIWrappingListContainer *)control)->SetRenderOffset(offset); } else if (type == CGUIControl::GUICONTAINER_EPGGRID) { control = new CGUIEPGGridContainer(parentID, id, posX, posY, width, height, orientation, scrollTime, preloadItems, timeBlocks, rulerUnit); ((CGUIEPGGridContainer *)control)->LoadLayout(pControlNode); ((CGUIEPGGridContainer *)control)->SetRenderOffset(offset); ((CGUIEPGGridContainer *)control)->SetType(viewType, viewLabel); } else if (type == CGUIControl::GUICONTAINER_FIXEDLIST) { CScroller scroller; GetScroller(pControlNode, "scrolltime", scroller); control = new CGUIFixedListContainer(parentID, id, posX, posY, width, height, orientation, scroller, preloadItems, focusPosition, iMovementRange); ((CGUIFixedListContainer *)control)->LoadLayout(pControlNode); ((CGUIFixedListContainer *)control)->LoadContent(pControlNode); ((CGUIFixedListContainer *)control)->SetDefaultControl(defaultControl, defaultAlways); ((CGUIFixedListContainer *)control)->SetType(viewType, viewLabel); ((CGUIFixedListContainer *)control)->SetPageControl(pageControl); ((CGUIFixedListContainer *)control)->SetRenderOffset(offset); } else if (type == CGUIControl::GUICONTAINER_PANEL) { CScroller scroller; GetScroller(pControlNode, "scrolltime", scroller); control = new CGUIPanelContainer(parentID, id, posX, posY, width, height, orientation, scroller, preloadItems); ((CGUIPanelContainer *)control)->LoadLayout(pControlNode); ((CGUIPanelContainer *)control)->LoadContent(pControlNode); ((CGUIPanelContainer *)control)->SetDefaultControl(defaultControl, defaultAlways); ((CGUIPanelContainer *)control)->SetType(viewType, viewLabel); ((CGUIPanelContainer *)control)->SetPageControl(pageControl); ((CGUIPanelContainer *)control)->SetRenderOffset(offset); } else if (type == CGUIControl::GUICONTROL_TEXTBOX) { control = new CGUITextBox( parentID, id, posX, posY, width, height, labelInfo, scrollTime); ((CGUITextBox *)control)->SetPageControl(pageControl); if (infoLabels.size()) ((CGUITextBox *)control)->SetInfo(infoLabels[0]); ((CGUITextBox *)control)->SetAutoScrolling(pControlNode); } else if (type == CGUIControl::GUICONTROL_SELECTBUTTON) { control = new CGUISelectButtonControl( parentID, id, posX, posY, width, height, textureFocus, textureNoFocus, labelInfo, textureBackground, textureLeft, textureLeftFocus, textureRight, textureRightFocus); ((CGUISelectButtonControl *)control)->SetLabel(strLabel); } else if (type == CGUIControl::GUICONTROL_MOVER) { control = new CGUIMoverControl( parentID, id, posX, posY, width, height, textureFocus, textureNoFocus); } else if (type == CGUIControl::GUICONTROL_RESIZE) { control = new CGUIResizeControl( parentID, id, posX, posY, width, height, textureFocus, textureNoFocus); } else if (type == CGUIControl::GUICONTROL_SPINEX) { control = new CGUISpinControlEx( parentID, id, posX, posY, width, height, spinWidth, spinHeight, labelInfo, textureFocus, textureNoFocus, textureUp, textureDown, textureUpFocus, textureDownFocus, labelInfo, iType); ((CGUISpinControlEx *)control)->SetSpinPosition(spinPosX); ((CGUISpinControlEx *)control)->SetText(strLabel); ((CGUISpinControlEx *)control)->SetReverse(bReverse); } else if (type == CGUIControl::GUICONTROL_VISUALISATION) { control = new CGUIVisualisationControl(parentID, id, posX, posY, width, height); } else if (type == CGUIControl::GUICONTROL_RENDERADDON) { control = new CGUIRenderingControl(parentID, id, posX, posY, width, height); } // things that apply to all controls if (control) { control->SetHitRect(hitRect); control->SetVisibleCondition(visibleCondition, allowHiddenFocus); control->SetEnableCondition(enableCondition); control->SetAnimations(animations); control->SetColorDiffuse(colorDiffuse); control->SetNavigationActions(upActions, downActions, leftActions, rightActions, backActions); control->SetPulseOnSelect(bPulse); if (hasCamera) control->SetCamera(camera); } return control; }
CGUIListItemLayout::CListBase *CGUIListItemLayout::CreateItem(TiXmlElement *child) { // resolve any <include> tag's in this control g_SkinInfo.ResolveIncludes(child); // grab the type... CStdString type = CGUIControlFactory::GetType(child); // resolve again with strType set so that <default> tags are added g_SkinInfo.ResolveIncludes(child, type); float posX = 0; float posY = 0; float width = 10; float height = 10; CStdString infoString; CImage image, borderImage; CImage imageFocus, imageNoFocus; FRECT borderSize = { 0, 0, 0, 0 }; CLabelInfo label; CGUIControlFactory::GetFloat(child, "posx", posX); CGUIControlFactory::GetFloat(child, "posy", posY); CGUIControlFactory::GetFloat(child, "width", width); CGUIControlFactory::GetFloat(child, "height", height); XMLUtils::GetString(child, "info", infoString); CGUIControlFactory::GetInfoColor(child, "textcolor", label.textColor); CGUIControlFactory::GetInfoColor(child, "selectedcolor", label.selectedColor); CGUIControlFactory::GetInfoColor(child, "shadowcolor", label.shadowColor); CGUIControlFactory::GetInfoColor(child, "focusedcolor", label.focusedColor); CStdString fontName; XMLUtils::GetString(child, "font", fontName); label.font = g_fontManager.GetFont(fontName); CGUIControlFactory::GetTexture(child, "texture", image); // reset the info file for this image as we want to handle the updating // when items change, rather than every frame if (!image.file.IsConstant()) image.file = CGUIInfoLabel(""); // and get the <info> tag for this as well if available (GetTexture doesn't handle <info>) CGUIInfoLabel infoTexture; CGUIControlFactory::GetInfoLabel(child, "texture", infoTexture); CGUIControlFactory::GetTexture(child, "texturefocus", imageFocus); CGUIControlFactory::GetTexture(child, "texturenofocus", imageNoFocus); CGUIControlFactory::GetAlignment(child, "align", label.align); FRECT rect = { posX, posY, width, height }; vector<CAnimation> animations; CGUIControlFactory::GetAnimations(child, rect, animations); CGUIInfoColor colorDiffuse(0xffffffff); CGUIControlFactory::GetInfoColor(child, "colordiffuse", colorDiffuse); DWORD alignY = 0; if (CGUIControlFactory::GetAlignmentY(child, "aligny", alignY)) label.align |= alignY; CGUIInfoLabel infoLabel; CGUIControlFactory::GetInfoLabel(child, "label", infoLabel); CGUIImage::CAspectRatio aspectRatio(CGUIImage::CAspectRatio::AR_KEEP); CGUIControlFactory::GetAspectRatio(child, "aspectratio", aspectRatio); int visibleCondition = 0; CGUIControlFactory::GetConditionalVisibility(child, visibleCondition); XMLUtils::GetFloat(child, "angle", label.angle); label.angle *= -1; bool scroll(false); XMLUtils::GetBoolean(child, "scroll", scroll); CGUIControlFactory::GetTexture(child, "bordertexture", borderImage); CStdString borderStr; if (XMLUtils::GetString(child, "bordersize", borderStr)) CGUIControlFactory::GetRectFromString(borderStr, borderSize); if (type == "label") { // info label return new CListLabel(posX, posY, width, height, visibleCondition, label, scroll, infoLabel, animations); } else if (type == "multiselect") { return new CListSelectLabel(posX, posY, width, height, visibleCondition, imageFocus, imageNoFocus, label, infoLabel, animations); } else if (type == "image") { if (!infoTexture.IsConstant()) return new CListImage(posX, posY, width, height, visibleCondition, image, borderImage, borderSize, aspectRatio, colorDiffuse, infoTexture, animations); else { // Due to old behaviour, we force aspectratio to stretch here aspectRatio.ratio = CGUIImage::CAspectRatio::AR_STRETCH; return new CListTexture(posX, posY, width, height, visibleCondition, image, borderImage, borderSize, aspectRatio, colorDiffuse, animations); } } return NULL; }