[longomatch] Add a new combobox for teams selection



commit 5d3b3975b83d10939ab0ab479c1254169325085e
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Mon Aug 18 19:15:58 2014 +0200

    Add a new combobox for teams selection

 LongoMatch.GUI/Gui/Component/TeamsComboBox.cs |   85 +++++++++++++++++++++++++
 1 files changed, 85 insertions(+), 0 deletions(-)
---
diff --git a/LongoMatch.GUI/Gui/Component/TeamsComboBox.cs b/LongoMatch.GUI/Gui/Component/TeamsComboBox.cs
new file mode 100644
index 0000000..47c83ea
--- /dev/null
+++ b/LongoMatch.GUI/Gui/Component/TeamsComboBox.cs
@@ -0,0 +1,85 @@
+//
+//  Copyright (C) 2014 Andoni Morales Alastruey
+//
+//  This program is free software; you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation; either version 2 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+using System;
+using Gtk;
+using LongoMatch.Common;
+using System.Collections.Generic;
+using LongoMatch.Store.Templates;
+using Gdk;
+
+namespace LongoMatch.Gui.Component
+{
+       [System.ComponentModel.Category("LongoMatch")]
+       [System.ComponentModel.ToolboxItem(true)]
+       public class TeamsComboBox: Gtk.ComboBox
+       {
+               ListStore store;
+               Button internalButton;
+               CellRendererPixbuf pixrender;
+               CellRendererText texrender;
+               
+               public TeamsComboBox (bool leftToRigt = true)
+               {
+               }
+
+               public void Load (List<TeamTemplate> teams, bool leftToRight)
+               {
+                       Clear ();
+                       pixrender = new CellRendererPixbuf ();
+                       texrender = new CellRendererText ();
+                       texrender.Font = StyleConf.NewTeamsFont;
+                       texrender.Alignment = Pango.Alignment.Center;
+
+                       if (leftToRight) {
+                               PackStart (pixrender, false);
+                               PackEnd (texrender, true);
+                       } else {
+                               PackEnd (pixrender, false);
+                               PackStart (texrender, true);
+                       }
+                       
+                       store = new ListStore (typeof(Pixbuf), typeof(string), typeof(TeamTemplate));
+                       foreach (TeamTemplate t in teams) {
+                               Pixbuf shield;
+                               int size = StyleConf.NewTeamsIconSize;
+
+                               if (t.Shield == null) {
+                                       shield = IconTheme.Default.LoadIcon (Constants.LOGO_ICON, size,
+                                                                            IconLookupFlags.ForceSvg);
+                               } else {
+                                       shield = t.Shield.Scale (size, size).Value;
+                               }
+                               store.AppendValues (shield, t.TeamName, t);
+                       }
+                       SetAttributes (texrender, "text", 1);
+                       SetAttributes (pixrender, "pixbuf", 0);
+                       Model = store;
+               
+               } 
+
+               public TeamTemplate ActiveTeam {
+                       get {
+                               TreeIter iter;
+
+                               GetActiveIter (out iter);
+                               return store.GetValue (iter, 2) as TeamTemplate;
+                       }
+               }
+       }
+}
+


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]