//-----------------------------------------------------------------------------
// 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); }
}
}
}
|