public ListStyle(ListStyle style) { Font = style.Font; FontColorSelected = style.FontColorSelected; FontColorUnselected = style.FontColorUnselected; Selection = style.Selection; }
public SelectBoxStyle(BitmapFont font, Color fontColor, ISceneDrawable background, ScrollPaneStyle scrollStyle, ListStyle listStyle) { Font = font; FontColor = fontColor; Background = background; ScrollStyle = scrollStyle; ListStyle = listStyle; }
public List(object[] items, ListStyle style) : this() { Style = style; SetItems(items); Width = PrefWidth; Height = PrefHeight; }
public void SetItems(object[] objects) { if (objects == null) { throw new ArgumentNullException("objects"); } _items = objects; if (!(objects is string[])) { string[] strings = new string[objects.Length]; for (int i = 0, n = objects.Length; i < n; i++) { strings[i] = objects[i].ToString(); } _itemsText = strings; } else { _itemsText = objects as string[]; } _selectionIndex = 0; ISceneDrawable bg = _style.Background; BitmapFont font = _style.Font; _prefHeight = Math.Max(bg.TopHeight + bg.BottomHeight + font.CapHeight - font.Descent * 2, bg.MinHeight); float maxItemWIdth = 0; for (int i = 0; i < _items.Length; i++) { maxItemWIdth = Math.Max(font.GetBounds(_itemsText[i]).Width, maxItemWIdth); } _prefWidth = bg.LeftWidth + bg.RightWidth + maxItemWIdth; ListStyle listStyle = _style.ListStyle; ScrollPaneStyle scrollStyle = _style.ScrollStyle; _prefWidth = Math.Max(_prefWidth, maxItemWIdth + scrollStyle.Background.LeftWidth + scrollStyle.Background.RightWidth + listStyle.Selection.LeftWidth + listStyle.Selection.RightWidth + Math.Max(_style.ScrollStyle.VScroll != null ? _style.ScrollStyle.VScroll.MinWidth : 0, _style.ScrollStyle.VScrollKnob != null ? _style.ScrollStyle.VScrollKnob.MinWidth : 0)); if (_items.Length > 0) { // TODO: Event for change of items //ChangeEvent changeEvent = Pools<ChangeEvent>.Obtain(); //Fire(changeEvent); //Pools<ChangeEvent>.Release(changeEvent); } InvalidateHierarchy(); }