ComboDropList.cs :  » Game » RealmForge » CrayzEdsGui » Base » Widgets » 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 » Widgets » ComboDropList.cs
using System;

namespace CrayzEdsGui.Base.Widgets{
  /// <summary>
  /// Summary description for ComboDropList.
  /// </summary>
  public abstract class ComboDropList : Listbox {
    #region Constructor

    /// <summary>
    ///    Constructor.
    /// </summary>
    /// <param name="name">Name of this widget.</param>
    public ComboDropList(string name) : base(name) {
      // hidden by default
      Hide();
    }

    #endregion Constructor

    #region Window Members

    #region Methods

    /// <summary>
    ///    Prepares this widget for use.
    /// </summary>
    public override void Initialize() {
      base.Initialize();

      // set-up scroll bars so they return capture to us.
      vertScrollbar.SetRestoreCapture(true);
      horzScrollbar.SetRestoreCapture(true);
    }

    #endregion Methods

    #endregion Window Members

    #region Events

    #region Declarations

    public event WindowEventHandler ListSelectionAccepted;

    #endregion Declarations

    #region Trigger Methods

    /// <summary>
    ///    Handles an item in the list being selected.
    /// </summary>
    /// <param name="e"></param>
    protected internal void OnListSelectionAccepted(WindowEventArgs e) {
      if(ListSelectionAccepted != null) {
        ListSelectionAccepted(this, e);
      }
    }

    #endregion Trigger Methods

    #region Overridden Trigger Methods

    /// <summary>
    ///    Handles mouse movement within this widget.
    /// </summary>
    /// <param name="e"></param>
    protected internal override void OnMouseMove(MouseEventArgs e) {
      base.OnMouseMove(e);

      // remove current selection
      ClearAllSelectionsImpl();

      // if mouse is within our area (but not children)
      if(IsHit(e.Position) && GetChildAtPosition(e.Position) == null) {
        // Convert mouse position to absolute window pixels
        Point localPos = ScreenToWindow(e.Position);

        if(this.MetricsMode == MetricsMode.Relative) {
          localPos = RelativeToAbsolute(localPos);
        }

        // check for an item under the mouse
        ListboxItem selectedItem = GetItemAtPoint(localPos);

        // if an item is under the mouse, select it
        if(selectedItem != null) {
          SetItemSelectState(selectedItem, true);
        }

        e.Handled = true;
      }
      else {
        // TODO: C++ version doesnt have this in an else, seems like value will never be true!
        e.Handled = false;
      }
    }

    /// <summary>
    ///    Handler for mouse button pressed events.
    /// </summary>
    /// <param name="e"></param>
    protected internal override void OnMouseButtonDown(MouseEventArgs e) {
      base.OnMouseButtonDown (e);

      if(e.Button == MouseButton.Left) {
        if(!IsHit(e.Position)) {
          ReleaseInput();
        }

        e.Handled = true;
      }
    }

    /// <summary>
    ///    Handler for mouse button release events.
    /// </summary>
    /// <param name="e"></param>
    protected internal override void OnMouseButtonUp(MouseEventArgs e) {
      base.OnMouseButtonUp (e);

      if(e.Button == MouseButton.Left) {
        ReleaseInput();

        // if something was selected, confirm that selection
        if(SelectedCount > 0) {
          OnListSelectionAccepted(new WindowEventArgs(this));
        }

        e.Handled = true;
      }
    }

    /// <summary>
    ///    Handler for when input capture is lost.
    /// </summary>
    /// <param name="e"></param>
    protected internal override void OnCaptureLost(GuiEventArgs e) {
      base.OnCaptureLost (e);

      Hide();

      e.Handled = true;
    }

    /// <summary>
    ///    Handler for when window is activated.
    /// </summary>
    /// <param name="e"></param>
    protected internal override void OnActivated(WindowEventArgs e) {
      base.OnActivated(e);
    }

    #endregion Overridden Trigger Methods

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