ComboBox.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 » ComboBox.cs
//-----------------------------------------------------------------------------
// wx.NET - ComboBox.cs
//
// The wxComboBox wrapper class.
//
// Written by Bryan Bulten (bryan@bulten.ca)
// (C) 2003 Bryan Bulten
//
// Complete revision: 2007 Harald Meyer auf'm Hofe
//
// Licensed under the wxWidgets license, see LICENSE.txt for details.
//
// $Id: ComboBox.cs,v 1.21 2007/11/11 14:14:45 harald_meyer Exp $
//-----------------------------------------------------------------------------

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

namespace wx{
    public class ComboBox : ControlWithItems
  {
    public const int wxCB_SIMPLE           = 0x0004;
    public const int wxCB_SORT             = 0x0008;
    public const int wxCB_READONLY         = 0x0010;
    public const int wxCB_DROPDOWN         = 0x0020;
    
    //---------------------------------------------------------------------
    
    [DllImport("wx-c")] static extern IntPtr wxComboBox_ctor();
        [DllImport("wx-c")] static extern bool wxComboBox_Create(IntPtr self, IntPtr window, int id, IntPtr value, ref Point pos, ref Size size, IntPtr choices, uint style, IntPtr validator, IntPtr name);
    
    [DllImport("wx-c")] static extern int    wxComboBox_GetSelection(IntPtr self);    
    [DllImport("wx-c")] static extern IntPtr wxComboBox_GetValue(IntPtr self);
        [DllImport("wx-c")] static extern void wxComboBox_SetValue(IntPtr self, IntPtr text);
    
    [DllImport("wx-c")] static extern void   wxComboBox_Copy(IntPtr self);
    [DllImport("wx-c")] static extern void   wxComboBox_Cut(IntPtr self);
    [DllImport("wx-c")] static extern void   wxComboBox_Paste(IntPtr self);
    
    [DllImport("wx-c")] static extern void   wxComboBox_SetInsertionPoint(IntPtr self, int pos);
    [DllImport("wx-c")] static extern int    wxComboBox_GetInsertionPoint(IntPtr self);
    [DllImport("wx-c")] static extern void   wxComboBox_SetInsertionPointEnd(IntPtr self);
    [DllImport("wx-c")] static extern int    wxComboBox_GetLastPosition(IntPtr self);

        [DllImport("wx-c")] static extern void   wxComboBox_Replace(IntPtr self, int from, int to, IntPtr value);
    [DllImport("wx-c")] static extern void   wxComboBox_SetSelection(IntPtr self, int from, int to);
    [DllImport("wx-c")] static extern void   wxComboBox_SetEditable(IntPtr self, bool editable);
    [DllImport("wx-c")] static extern void   wxComboBox_Remove(IntPtr self, int from, int to);
    
    [DllImport("wx-c")] static extern void wxComboBox_SetSelection(IntPtr self, int n);
    
    [DllImport("wx-c")] static extern void wxComboBox_Select(IntPtr self, int n);
    
    //---------------------------------------------------------------------
  
    public ComboBox(IntPtr wxObject) 
      : base(wxObject) { }

    public ComboBox()
      : base(wxComboBox_ctor()) { }

    public ComboBox(Window parent, int id)
      : this(parent, id, "", wxDefaultPosition, wxDefaultSize, (string[])null, 0, null, null) { }

        public ComboBox(Window parent, int id, string value, Point pos, Size size, string[] choices)
            : this(parent, id, new wxString(value), pos, size, ArrayString.SafeNewFrom(choices), 0, null, null) { }

        public ComboBox(Window parent, int id, string value, Point pos, Size size, string[] choices, uint style)
            : this(parent, id, new wxString(value), pos, size, ArrayString.SafeNewFrom(choices), style, null, null) { }

        public ComboBox(Window parent, int id, string value, Point pos, Size size, string[] choices, uint style, Validator val)
            : this(parent, id, new wxString(value), pos, size, ArrayString.SafeNewFrom(choices), style, val, null) { }

        public ComboBox(Window parent, int id, string value, Point pos, Size size, string[] choices, uint style, Validator validator, string name)
            : this(parent, id, new wxString(value), pos, size, ArrayString.SafeNewFrom(choices), style, validator, new wxString(name))
        {
        }

        internal ComboBox(Window parent, int id, 
        wxString value, Point pos, Size size,
                ArrayString choices, uint style, Validator validator, 
        wxString name)
      : base(wxComboBox_ctor())
    {
      if(!wxComboBox_Create(wxObject, Object.SafePtr(parent), id, 
            Object.SafePtr(value), ref pos, ref size, 
            Object.SafePtr(choices), style, 
            Object.SafePtr(validator), Object.SafePtr(name))) 
      {
        throw new InvalidOperationException("Failed to create ListBox");
      }
    }
    
    //---------------------------------------------------------------------
    // ctors with self created id
    
    public ComboBox(Window parent)
      : this(parent, Window.UniqueID, "", wxDefaultPosition, wxDefaultSize, (string[]) null, 0, null, null) { }

    public ComboBox(Window parent, string value, Point pos, Size size, string[] choices)
            : this(parent, Window.UniqueID, new wxString(value), pos, size, ArrayString.SafeNewFrom(choices), 0, null, null) { }

    public ComboBox(Window parent, string value, Point pos, Size size, string[] choices, uint style)
            : this(parent, Window.UniqueID, new wxString(value), pos, size, ArrayString.SafeNewFrom(choices), style, null, null) { }

    public ComboBox(Window parent, string value, Point pos, Size size, string[] choices, uint style, Validator val)
            : this(parent, Window.UniqueID, new wxString(value), pos, size, ArrayString.SafeNewFrom(choices), style, val, null) { }

    public ComboBox(Window parent,  
                string value, Point pos, Size size, 
                string[] choices, uint style, Validator validator, 
                string name)
            : this(parent, Window.UniqueID, new wxString(value), pos, size, ArrayString.SafeNewFrom(choices), style, validator, new wxString(name)) { }
    
    //---------------------------------------------------------------------

    public bool Create(Window parent, int id, string value, 
                    Point pos, Size size,
                    string[] choices, uint style, Validator validator,
                    string name)
    {
            return this.Create(parent, id,
                      new wxString(value), pos, size, 
                      ArrayString.SafeNewFrom(choices), 
                      style, validator, new wxString(name));
    }
        internal bool Create(Window parent, int id, wxString value,
                            Point pos, Size size,
                            ArrayString choices, uint style, Validator validator,
                            wxString name)
        {
            return wxComboBox_Create(wxObject, Object.SafePtr(parent), id,
                                    Object.SafePtr(value), ref pos, ref size,
                                    Object.SafePtr(choices),
                                    (uint)style, Object.SafePtr(validator), Object.SafePtr(name));
        }

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


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

    public void Copy()
    {
      wxComboBox_Copy(this.wxObject);
    }
    
    //---------------------------------------------------------------------

    public void Cut()
    {
      wxComboBox_Cut(this.wxObject);
    }
    
    //---------------------------------------------------------------------

    public void Paste()
    {
      wxComboBox_Paste(this.wxObject);
    }

    //---------------------------------------------------------------------
        
    public int InsertionPoint
    {
      get { return wxComboBox_GetInsertionPoint(this.wxObject); }
      set { wxComboBox_SetInsertionPoint(this.wxObject, value); }
    }
    
    //---------------------------------------------------------------------

    public void SetInsertionPointEnd()
    {
      wxComboBox_SetInsertionPointEnd(this.wxObject);
    }
    
    //---------------------------------------------------------------------

    public int GetLastPosition()
    {
      return wxComboBox_GetLastPosition(this.wxObject);
    }

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

    public void Replace(int from, int to, string value)
    {
            wxString wxValue = new wxString(value);
      wxComboBox_Replace(wxObject, from, to, wxValue.wxObject);
    }

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

        /** Refer to ControlWithItems for the method receiving only one index.
         * */
    public void SetSelection(int from, int to)
    {
      wxComboBox_SetSelection(this.wxObject, from, to);
    }
    
    //---------------------------------------------------------------------

    public bool Editable
    {
            set { wxComboBox_SetEditable(this.wxObject, value); }
    }

    //---------------------------------------------------------------------
        
    public void Remove(int from, int to)
    {
      wxComboBox_Remove(wxObject, from, to);
    }

    //---------------------------------------------------------------------
        
    public string Value
    {
      get { return new wxString(wxComboBox_GetValue(wxObject)); }
      set
            {
                wxString wxValue = new wxString(value);
                wxComboBox_SetValue(this.wxObject, wxValue.wxObject);
            }
    }
    
    public void Select(int n)
    {
      wxComboBox_Select(this.wxObject, n);
    }

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

    public event EventListener Selected
    {
      add { AddCommandListener(Event.wxEVT_COMMAND_COMBOBOX_SELECTED, 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.