SpinCtrl.cs :  » GUI » wx-NET » wx » 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 » GUI » wx NET 
wx NET » wx » SpinCtrl.cs
//-----------------------------------------------------------------------------
// wx.NET - SpinCtrl.cs
//
// The wxSpinCtrl wrapper class.
//
// Written by Bryan Bulten (bryan@bulten.ca)
// (C) 2003 Bryan Bulten
// Licensed under the wxWidgets license, see LICENSE.txt for details.
//
// $Id: SpinCtrl.cs,v 1.13 2007/11/24 17:55:46 harald_meyer Exp $
//-----------------------------------------------------------------------------

using System;
using System.Drawing;
using System.Runtime.InteropServices;

namespace wx{
  public class SpinCtrl : Control 
  {
    // These are duplicated in SpinButton.cs (for easier access)
    public const int wxSP_HORIZONTAL       = Orientation.wxHORIZONTAL;
    public const int wxSP_VERTICAL         = Orientation.wxVERTICAL;
    public const int wxSP_ARROW_KEYS       = 0x1000;
    public const int wxSP_WRAP             = 0x2000;
  
    //---------------------------------------------------------------------
    
    [DllImport("wx-c")] static extern IntPtr wxSpinCtrl_ctor();
    [DllImport("wx-c")][return: MarshalAs(UnmanagedType.U1)] static extern bool   wxSpinCtrl_Create(IntPtr self, IntPtr parent, int id, IntPtr value, int posX, int posY, int width, int height, uint style, int min, int max, int initial, IntPtr name);
    [DllImport("wx-c")] static extern int    wxSpinCtrl_GetValue(IntPtr self);
    [DllImport("wx-c")] static extern int    wxSpinCtrl_GetMin(IntPtr self);
    [DllImport("wx-c")] static extern int    wxSpinCtrl_GetMax(IntPtr self);
    [DllImport("wx-c")] static extern void   wxSpinCtrl_SetValueStr(IntPtr self, IntPtr value);
    [DllImport("wx-c")] static extern void   wxSpinCtrl_SetValue(IntPtr self, int val);
    [DllImport("wx-c")] static extern void   wxSpinCtrl_SetRange(IntPtr self, int min, int max);
  
    //---------------------------------------------------------------------
    
    public SpinCtrl(IntPtr wxObject) 
      : base(wxObject) {}

    public SpinCtrl()
      : base(wxSpinCtrl_ctor()) { }

    public SpinCtrl(Window parent, int id)
      : this(parent, id, "", wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 100, 0, null ) { }

    public SpinCtrl(Window parent, int id, string value)
      : this(parent, id, value, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 100, 0, null ) { }

    public SpinCtrl(Window parent, int id, string value, Point pos, Size size)
      : this(parent, id, value, pos, size, wxSP_ARROW_KEYS, 0, 100, 0, null ) { }

    public SpinCtrl(Window parent, int id, string value, Point pos, Size size, uint style)
      : this(parent, id, value, pos, size, style, 0, 100, 0, null ) { }

    public SpinCtrl(Window parent, int id, string value, Point pos, Size size, uint style, int min, int max, int initial)
      : this(parent, id, value, pos, size, style, min, max, initial, null ) { }

    public SpinCtrl(Window parent, int id, string value, Point pos, Size size, uint style, int min, int max, int initial, string name)
      : base(wxSpinCtrl_ctor())
    {
      if(!Create(parent, id, value, pos, size, style, min, max, initial, name))
      {
        throw new InvalidOperationException("Failed to create SpinCtrl");
      }
    }
    
    //---------------------------------------------------------------------
    // ctors with self created id
    
    public SpinCtrl(Window parent)
      : this(parent, Window.UniqueID, "", wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 100, 0, null ) { }

    public SpinCtrl(Window parent, string value)
      : this(parent, Window.UniqueID, value, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 100, 0, null ) { }

    public SpinCtrl(Window parent, string value, Point pos, Size size)
      : this(parent, Window.UniqueID, value, pos, size, wxSP_ARROW_KEYS, 0, 100, 0, null ) { }

    public SpinCtrl(Window parent, string value, Point pos, Size size, uint style)
      : this(parent, Window.UniqueID, value, pos, size, style, 0, 100, 0, null ) { }

    public SpinCtrl(Window parent, string value, Point pos, Size size, uint style, int min, int max, int initial)
      : this(parent, Window.UniqueID, value, pos, size, style, min, max, initial, null ) { }

    public SpinCtrl(Window parent, string value, Point pos, Size size, uint style, int min, int max, int initial, string name)
      : this(parent, Window.UniqueID, value, pos, size, style, min, max, initial, name) {}
    
    //---------------------------------------------------------------------

        public bool Create(Window parent, int id, string value, Point pos, Size size, uint style, int min, int max, int initial, string name)
        {
            return this.Create(parent, id, wxString.SafeNew(value), pos, size, style, min, max, initial, wxString.SafeNew(name));
        }
    public bool Create(Window parent, int id, wxString value, Point pos, Size size, uint style, int min, int max, int initial, wxString name)
    {
      return wxSpinCtrl_Create(wxObject, Object.SafePtr(parent), id, 
          Object.SafePtr(value), pos.X, pos.Y, size.Width, size.Height, style, min,
          max, initial, Object.SafePtr(name));
    }

    //---------------------------------------------------------------------

    public int Value
    {
      get { return wxSpinCtrl_GetValue(wxObject); }
      set
            {
                wxSpinCtrl_SetValue(wxObject, value);
            }
    }

    public void SetValue(string val)
    {
            wxString wxvalue = wxString.SafeNew(val);
            wxSpinCtrl_SetValueStr(wxObject, Object.SafePtr(wxvalue));
    }

    //---------------------------------------------------------------------
        
    public int Max
    {
      get { return wxSpinCtrl_GetMax(wxObject); }
    }

    public int Min
    {
      get { return wxSpinCtrl_GetMin(wxObject); }
    }

    public void SetRange(int min, int max)
    {
      wxSpinCtrl_SetRange(wxObject, min, max);
    }

    //---------------------------------------------------------------------

    public override event EventListener UpdateUI
    {
      add { AddCommandListener(Event.wxEVT_COMMAND_SPINCTRL_UPDATED, ID, value, this); }
      remove { RemoveHandler(value, this); }
    }
  }
}

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