RadioBox.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 » RadioBox.cs
//-----------------------------------------------------------------------------
// wx.NET - RadioBox.cs
//
// The wxRadioBox wrapper class.
//
// Written by Jason Perkins (jason@379.com)
// (C) 2003 by 379, Inc.
// Licensed under the wxWidgets license, see LICENSE.txt for details.
//
// $Id: RadioBox.cs,v 1.15 2007/11/11 14:14:46 harald_meyer Exp $
//-----------------------------------------------------------------------------

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

namespace wx{
    /** This control throws exceptions on generating / creating instances without choices.
     * According to the \w wxWidgets documentation, this is a control with items but it is not.
     * You can neither add items dynamically not associate items with client data.
     */
  public class RadioBox : Control
  {
    public const int wxRA_LEFTTORIGHT    = 0x0001;
    public const int wxRA_TOPTOBOTTOM    = 0x0002;
    public const int wxRA_SPECIFY_COLS   = Orientation.wxHORIZONTAL;
    public const int wxRA_SPECIFY_ROWS   = Orientation.wxVERTICAL;
    public const int wxRA_HORIZONTAL     = Orientation.wxHORIZONTAL;
    public const int wxRA_VERTICAL       = Orientation.wxVERTICAL;

    //---------------------------------------------------------------------
        
    [DllImport("wx-c")] static extern IntPtr wxRadioBox_ctor();
    [DllImport("wx-c")] static extern bool   wxRadioBox_Create(IntPtr self, IntPtr parent, int id,
                                                               IntPtr label, ref Point pos, ref Size size,
                                                               IntPtr choices, int majorDimension,
                                                               uint style, IntPtr val, IntPtr name);

    [DllImport("wx-c")] static extern void   wxRadioBox_Enable(IntPtr self, int n, bool enable);
    [DllImport("wx-c")] static extern void   wxRadioBox_Show(IntPtr self, int n, bool show);

        [DllImport("wx-c")] static extern int wxRadioBox_FindString(IntPtr self, IntPtr aString);
        [DllImport("wx-c")] static extern int wxRadioBox_GetSelection(IntPtr self);
        [DllImport("wx-c")] static extern void wxRadioBox_SetSelection(IntPtr self, int item);
        [DllImport("wx-c")] static extern IntPtr wxRadioBox_GetStringSelection(IntPtr self);
        [DllImport("wx-c")] static extern void wxRadioBox_SetStringSelection(IntPtr self, IntPtr aString);
        [DllImport("wx-c")] static extern IntPtr wxRadioBox_GetString(IntPtr self, int n);

        [DllImport("wx-c")] static extern int wxRadioBox_GetCount(IntPtr self);

    [DllImport("wx-c")] static extern IntPtr wxRadioBox_GetLabel(IntPtr self);
    [DllImport("wx-c")] static extern void   wxRadioBox_SetLabel(IntPtr self, IntPtr label);

    //---------------------------------------------------------------------
    
    public RadioBox(IntPtr wxObject)
      : base(wxObject) {}
      
    public RadioBox(Window parent, int id, string label, Point pos, Size size, string[] choices)
      : this(parent, id, label, pos, size, choices, 0, wxRA_SPECIFY_COLS, null, "radioBox") {} 
      
    public RadioBox(Window parent, int id, string label, Point pos, Size size, string[] choices, int majorDimension)
      : this(parent, id, label, pos, size, choices, majorDimension, wxRA_SPECIFY_COLS, null, "radioBox") {} 

    public RadioBox(Window parent, int id, string label, Point pos, Size size, string[] choices, int majorDimension, uint style)
      : this(parent, id, label, pos, size, choices, majorDimension, style, null, null) { }
      
    public RadioBox(Window parent, int id, string label, Point pos, Size size, string[] choices, int majorDimension, uint style, Validator validator)
      : this(parent, id, label, pos, size, choices, majorDimension, style, validator, null) { }

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

    internal RadioBox(Window parent, int id, wxString label, Point pos, Size size, ArrayString choices, int majorDimension, uint style, Validator val, wxString name)
      : base(wxRadioBox_ctor())
    {
      if (!wxRadioBox_Create(wxObject, Object.SafePtr(parent), id, Object.SafePtr(label), ref pos, ref size,
                             Object.SafePtr(choices), majorDimension, (uint)style, Object.SafePtr(val), Object.SafePtr(name)))
      {
        throw new InvalidOperationException("failed to create checkbox");
      }
    }
    
    //---------------------------------------------------------------------
    // ctors with self created id
    
    public RadioBox(Window parent, string label)
            : this(parent, Window.UniqueID, label, wxDefaultPosition, wxDefaultSize, new string[] { }, 0, wxRA_SPECIFY_COLS, null, "radioBox") { } 
      
    public RadioBox(Window parent, string label, Point pos)
            : this(parent, Window.UniqueID, label, pos, wxDefaultSize, new string[] { }, 0, wxRA_SPECIFY_COLS, null, "radioBox") { } 
      
    public RadioBox(Window parent, string label, Point pos, Size size)
            : this(parent, Window.UniqueID, label, pos, size, new string[] { }, 0, wxRA_SPECIFY_COLS, null, "radioBox") { } 
      
    public RadioBox(Window parent, string label, Point pos, Size size, string[] choices)
      : this(parent, Window.UniqueID, label, pos, size, choices, 0, wxRA_SPECIFY_COLS, null, "radioBox") {} 
      
    public RadioBox(Window parent, string label, Point pos, Size size, string[] choices, int majorDimension)
      : this(parent, Window.UniqueID, label, pos, size, choices, majorDimension, wxRA_SPECIFY_COLS, null, "radioBox") {} 

    public RadioBox(Window parent, string label, Point pos, Size size, string[] choices, int majorDimension, uint style)
      : this(parent, Window.UniqueID, label, pos, size, choices, majorDimension, style, null, null) { }
      
    public RadioBox(Window parent, string label, Point pos, Size size, string[] choices, int majorDimension, uint style, Validator validator)
      : this(parent, Window.UniqueID, label, pos, size, choices, majorDimension, style, validator, null) { }

    public RadioBox(Window parent, string label, Point pos, Size size, string[] choices, int majorDimension, uint style, Validator val, string name)
      : this(parent, Window.UniqueID, label, pos, size, choices, majorDimension, style, val, name) {}

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

    public void Enable(int n, bool enable)
    {
      wxRadioBox_Enable(wxObject, n, enable);
    }

    public void Show(int n, bool show)
    {
      wxRadioBox_Show(wxObject, n , show);
    }

        public int FindString(string aString)
        {
            return this.FindString(new wxString(aString));
        }

        public int FindString(wxString aString)
        {
            return wxRadioBox_FindString(this.wxObject, aString.wxObject);
        }

        public int Count
        {
            get { return wxRadioBox_GetCount(this.wxObject); }
        }

        public int Selection
        {
            get { return wxRadioBox_GetSelection(this.wxObject); }
            set { wxRadioBox_SetSelection(this.wxObject, value); }
        }

        public string StringSelection
        {
            get { return new wxString(wxRadioBox_GetStringSelection(this.wxObject)); }
            set { wxString wxValue = new wxString(value); wxRadioBox_SetStringSelection(this.wxObject, wxValue.wxObject); }
        }

    //---------------------------------------------------------------------
    
    public new string Label
    {
      get { return new wxString(wxRadioBox_GetLabel(wxObject), true); }
      set
            {
                wxString wxValue = new wxString(value);
                wxRadioBox_SetLabel(wxObject, wxValue.wxObject);
            }
    }
    
    //---------------------------------------------------------------------

    public event EventListener Select
    {
      add { AddCommandListener(Event.wxEVT_COMMAND_RADIOBOX_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.