ListboxTextItem.cs :  » Game » RealmForge » CrayzEdsGui » Base » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Game » RealmForge 
RealmForge » CrayzEdsGui » Base » ListboxTextItem.cs
using System;

namespace CrayzEdsGui.Base{
  /// <summary>
  /// Summary description for ListboxTextItem.
  /// </summary>
  public class ListboxTextItem : ListboxItem
  {
    #region Fields
    /// <summary>
    /// Font to use for text rendering.
    /// </summary>
    protected Font font = null;

    /// <summary>
    /// Colors to use when rendering text.
    /// </summary>
    protected ColorRect textColors;
    #endregion

    #region Properties
    /// <summary>
    /// Get/Set the font used for text rendering.
    /// </summary>
    public Font Font {
      get {
        // prefer out own font
        if (font != null) {
          return font;
        }
        // try our owner window's font setting (may be null if owner uses no existant default font)
        else if (owner != null) {
          return owner.Font;
        }
        // no owner, just use the default (which may be null anyway)
        else {
          return GuiSystem.Instance.DefaultFont;
        }
      }

      set {
        font = value;
      }
    }

    /// <summary>
    /// Get/Set the text colors for this ListboxItem.
    /// </summary>
    public ColorRect TextColors 
    {
      get 
      {
        return textColors;
      }

      set 
      {
        textColors = value;
      }
    }

    #endregion

    #region Constructors

    public ListboxTextItem() :
      base(string.Empty)
    {
      textColors = new ColorRect(
        new Color(1,1,1),
        new Color(1,1,1),
        new Color(1,1,1),
        new Color(1,1,1)
        );
    }

    public ListboxTextItem(string text) :
      base(text)
    {
      textColors = new ColorRect(
        new Color(1,1,1),
        new Color(1,1,1),
        new Color(1,1,1),
        new Color(1,1,1)
        );
    }

    public ListboxTextItem(string text, int itemID, object itemData, bool itemDisabled) :
      base(text, itemID, itemData, itemDisabled)
    {
      textColors = new ColorRect(
        new Color(1,1,1),
        new Color(1,1,1),
        new Color(1,1,1),
        new Color(1,1,1)
        );
    }

    #endregion

    #region Methods
    /// <summary>
    /// Set the colors to use for the text.
    /// </summary>
    /// <param name="topLeft"></param>
    /// <param name="topRight"></param>
    /// <param name="bottomLeft"></param>
    /// <param name="bottomRight"></param>
    public void SetTextColors(Color topLeft, Color topRight, Color bottomLeft, Color bottomRight)
    {
      textColors = new ColorRect(topLeft, topRight, bottomLeft, bottomRight);
    }

    /// <summary>
    /// Set the text color to be used.
    /// </summary>
    /// <param name="color"></param>
    public void SetTextColors(Color color)
    {
      textColors = new ColorRect(color, color, color, color);
    }

    #endregion

    #region Base Class Methods

    #region Properties

    /// <summary>
    /// Return the pixel size of this ListboxItem.
    /// </summary>
    public override Size Size 
    {
      get {
        Size tmp = new Size(0,0);

        Font fnt = Font;

        if (fnt != null) {
          tmp.height  = fnt.LineSpacing;
          tmp.width  = fnt.GetTextExtent(itemText);
        }

        return tmp;
      }
    }

    #endregion

    #region Methods

    /// <summary>
    /// Perform rendering for this ListboxItem
    /// </summary>
    /// <param name="position">Vector3 object describing the upper-left corner of area that should be rendered in to for the draw operation.</param>
    /// <param name="alpha">Alpha value to be used when rendering the item (between 0.0f and 1.0f).</param>
    /// <param name="clipper">Rect object describing the clipping rectangle for the draw operation.</param>
    public override void Draw(Vector3 position, float alpha, Rect clipper)
    {
      if (selected && (selectBrushImage != null)) {
        selectBrushImage.Draw(clipper, GuiSystem.Instance.Renderer.GetZLayer(2), clipper, GetModulateAlphaColourRect(selectColors, alpha));
      }

      Font fnt = Font;

      if (fnt != null) {
        position.z = GuiSystem.Instance.Renderer.GetZLayer(3);
        fnt.DrawText(itemText, position, clipper, GetModulateAlphaColourRect(textColors, alpha));
      }
    }

    #endregion

    #endregion
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.