CheckBox.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 » CheckBox.cs
//-----------------------------------------------------------------------------
// wx.NET - CheckBox.cs
//
// The wxCheckBox 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: CheckBox.cs,v 1.15 2007/11/11 14:14:45 harald_meyer Exp $
//-----------------------------------------------------------------------------

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

namespace wx{
  public enum CheckBoxState
  {
    wxCHK_UNCHECKED,
    wxCHK_CHECKED,
    wxCHK_UNDETERMINED
  }
  
  //---------------------------------------------------------------------

  public class CheckBox : Control
  {
    public const int wxCHK_2STATE           = 0x0000;
    public const int wxCHK_3STATE           = 0x1000;
    public const int wxCHK_ALLOW_3RD_STATE_FOR_USER           = 0x2000;
  
    [DllImport("wx-c")] static extern IntPtr wxCheckBox_ctor();
    [DllImport("wx-c")] static extern bool   wxCheckBox_Create(IntPtr self, IntPtr parent, int id, IntPtr label, int posX, int posY, int width, int height, uint style, IntPtr val, IntPtr name);
    [DllImport("wx-c")] static extern bool   wxCheckBox_GetValue(IntPtr self);
    [DllImport("wx-c")] static extern void   wxCheckBox_SetValue(IntPtr self, bool state);
    [DllImport("wx-c")] static extern bool   wxCheckBox_IsChecked(IntPtr self);
    
    [DllImport("wx-c")] static extern CheckBoxState wxCheckBox_Get3StateValue(IntPtr self);
    [DllImport("wx-c")] static extern void wxCheckBox_Set3StateValue(IntPtr self, CheckBoxState state);
    [DllImport("wx-c")] static extern bool wxCheckBox_Is3State(IntPtr self);
    [DllImport("wx-c")] static extern bool wxCheckBox_Is3rdStateAllowedForUser(IntPtr self);

    //---------------------------------------------------------------------
    
    public CheckBox(IntPtr wxObject) 
      : base(wxObject) {}
      
    public CheckBox()
      : this(wxCheckBox_ctor()) { }

    public CheckBox(Window parent, int id, string label)
      : this(parent, id, label, wxDefaultPosition, wxDefaultSize, 0, null, null) { }

    public CheckBox(Window parent, int id, string label, Point pos)
            : this(parent, id, label, pos, wxDefaultSize, 0, null, null) { }

    public CheckBox(Window parent, int id, string label, Point pos, Size size)
            : this(parent, id, label, pos, size, 0, null, null) { }

    public CheckBox(Window parent, int id, string label, Point pos, Size size, uint style)
            : this(parent, id, label, pos, size, style, null, null) { }

    public CheckBox(Window parent, int id, string label, Point pos, Size size, uint style, Validator val)
            : this(parent, id, label, pos, size, style, val, null) { }

    public CheckBox(Window parent, int id, string label, Point pos, Size size, uint style, Validator val, string name)
      : this(wxCheckBox_ctor())
    {
            wxString wxLabel = wxString.SafeNew(label);
            wxString wxName = wxString.SafeNew(name);
      if (!wxCheckBox_Create(wxObject, Object.SafePtr(parent), id,
                             Object.SafePtr(wxLabel), pos.X, pos.Y, size.Width, size.Height, (uint)style, Object.SafePtr(val),
                                   Object.SafePtr(wxName)))
      {
        throw new InvalidOperationException("failed to create checkbox");
      }
    }
    
    //---------------------------------------------------------------------
    // ctors with self created id
    
    public CheckBox(Window parent, string label)
      : this(parent, Window.UniqueID, label, wxDefaultPosition, wxDefaultSize, 0, null, null) { }

    public CheckBox(Window parent, string label, Point pos)
            : this(parent, Window.UniqueID, label, pos, wxDefaultSize, 0, null, null) { }

    public CheckBox(Window parent, string label, Point pos, Size size)
            : this(parent, Window.UniqueID, label, pos, size, 0, null, null) { }

    public CheckBox(Window parent, string label, Point pos, Size size, uint style)
            : this(parent, Window.UniqueID, label, pos, size, style, null, null) { }

    public CheckBox(Window parent, string label, Point pos, Size size, uint style, Validator val)
            : this(parent, Window.UniqueID, label, pos, size, style, val, null) { }

    public CheckBox(Window parent, string label, Point pos, Size size, uint style, Validator val, string name)
      : this(parent, Window.UniqueID, label, pos, size, style, val, name) {}
    
    //---------------------------------------------------------------------

    public bool Create(Window parent, int id, string label, Point pos, Size size,
      uint style, Validator val, string name)
    {
            wxString wxLabel = wxString.SafeNew(label);
            wxString wxName = wxString.SafeNew(name);
      return wxCheckBox_Create(wxObject, Object.SafePtr(parent), id,
                                      Object.SafePtr(wxLabel), pos.X, pos.Y,
                                      size.Width, size.Height, (uint)style, Object.SafePtr(val), Object.SafePtr(wxName));
    }

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

    public bool Value
    {
      get { return wxCheckBox_GetValue(wxObject); }
      set { wxCheckBox_SetValue(wxObject, value); }
    }

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

    public bool IsChecked
    {
      get { return wxCheckBox_IsChecked(wxObject); }
    }
    
    //---------------------------------------------------------------------
    
    public CheckBoxState ThreeStateValue
    {
      get { return wxCheckBox_Get3StateValue(wxObject); }
      set { wxCheckBox_Set3StateValue(wxObject, value); }
    }
    
    //---------------------------------------------------------------------
    
    public bool Is3State()
    {
      return wxCheckBox_Is3State(wxObject);
    }

    //---------------------------------------------------------------------
    
    public bool Is3rdStateAllowedForUser()
    {
      return wxCheckBox_Is3rdStateAllowedForUser(wxObject);
    }
    
    //---------------------------------------------------------------------
        
    public event EventListener Clicked
    {
      add { AddCommandListener(Event.wxEVT_COMMAND_CHECKBOX_CLICKED, 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.