2001-06-26 16:59:19 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/checkbox.h
|
|
|
|
// Purpose: wxCheckBox class interface
|
|
|
|
// Author: Vadim Zeitlin
|
|
|
|
// Modified by:
|
|
|
|
// Created: 07.09.00
|
|
|
|
// RCS-ID: $Id$
|
2004-05-23 10:56:36 -04:00
|
|
|
// Copyright: (c) wxWidgets team
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
2001-06-26 16:59:19 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1998-08-14 20:23:28 -04:00
|
|
|
#ifndef _WX_CHECKBOX_H_BASE_
|
|
|
|
#define _WX_CHECKBOX_H_BASE_
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2003-07-09 17:48:53 -04:00
|
|
|
#include "wx/defs.h"
|
|
|
|
|
2001-06-26 16:59:19 -04:00
|
|
|
#if wxUSE_CHECKBOX
|
|
|
|
|
|
|
|
#include "wx/control.h"
|
|
|
|
|
2003-09-27 20:23:08 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* wxCheckBox style flags
|
|
|
|
* (Using wxCHK_* because wxCB_* is used by wxComboBox).
|
|
|
|
* Determine whether to use a 3-state or 2-state
|
|
|
|
* checkbox. 3-state enables to differentiate
|
|
|
|
* between 'unchecked', 'checked' and 'undetermined'.
|
|
|
|
*/
|
|
|
|
#define wxCHK_2STATE 0x0000
|
|
|
|
#define wxCHK_3STATE 0x1000
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If this style is set the user can set the checkbox to the
|
|
|
|
* undetermined state. If not set the undetermined set can only
|
|
|
|
* be set programmatically.
|
|
|
|
* This style can only be used with 3 state checkboxes.
|
|
|
|
*/
|
|
|
|
#define wxCHK_ALLOW_3RD_STATE_FOR_USER 0x2000
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The possible states of a 3-state checkbox (Compatible
|
|
|
|
* with the 2-state checkbox).
|
|
|
|
*/
|
|
|
|
enum wxCheckBoxState
|
|
|
|
{
|
|
|
|
wxCHK_UNCHECKED,
|
|
|
|
wxCHK_CHECKED,
|
|
|
|
wxCHK_UNDETERMINED /* 3-state checkbox only */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
extern WXDLLIMPEXP_DATA_CORE(const char) wxCheckBoxNameStr[];
|
2001-06-26 16:59:19 -04:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxCheckBox: a control which shows a label and a box which may be checked
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxCheckBoxBase : public wxControl
|
2001-06-26 16:59:19 -04:00
|
|
|
{
|
|
|
|
public:
|
2004-01-15 08:49:22 -05:00
|
|
|
wxCheckBoxBase() { }
|
2003-07-21 20:24:07 -04:00
|
|
|
|
2001-06-26 16:59:19 -04:00
|
|
|
// set/get the checked status of the listbox
|
2003-09-28 14:01:42 -04:00
|
|
|
virtual void SetValue(bool value) = 0;
|
2001-06-26 16:59:19 -04:00
|
|
|
virtual bool GetValue() const = 0;
|
|
|
|
|
2003-09-27 20:23:08 -04:00
|
|
|
bool IsChecked() const
|
|
|
|
{
|
|
|
|
wxASSERT_MSG( !Is3State(), wxT("Calling IsChecked() doesn't make sense for")
|
|
|
|
wxT(" a three state checkbox, Use Get3StateValue() instead") );
|
|
|
|
|
|
|
|
return GetValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
wxCheckBoxState Get3StateValue() const
|
|
|
|
{
|
|
|
|
wxCheckBoxState state = DoGet3StateValue();
|
|
|
|
|
|
|
|
if ( state == wxCHK_UNDETERMINED && !Is3State() )
|
|
|
|
{
|
|
|
|
// Undetermined state with a 2-state checkbox??
|
|
|
|
wxFAIL_MSG( wxT("DoGet3StateValue() says the 2-state checkbox is ")
|
|
|
|
wxT("in an undetermined/third state") );
|
|
|
|
|
|
|
|
state = wxCHK_UNCHECKED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Set3StateValue(wxCheckBoxState state)
|
|
|
|
{
|
|
|
|
if ( state == wxCHK_UNDETERMINED && !Is3State() )
|
|
|
|
{
|
|
|
|
wxFAIL_MSG(wxT("Setting a 2-state checkbox to undetermined state"));
|
|
|
|
state = wxCHK_UNCHECKED;
|
|
|
|
}
|
|
|
|
|
|
|
|
DoSet3StateValue(state);
|
|
|
|
}
|
|
|
|
|
2003-10-15 18:45:23 -04:00
|
|
|
bool Is3State() const { return HasFlag(wxCHK_3STATE); }
|
2003-09-27 20:23:08 -04:00
|
|
|
|
|
|
|
bool Is3rdStateAllowedForUser() const
|
|
|
|
{
|
2003-10-15 18:45:23 -04:00
|
|
|
return HasFlag(wxCHK_ALLOW_3RD_STATE_FOR_USER);
|
2003-09-27 20:23:08 -04:00
|
|
|
}
|
|
|
|
|
2005-01-07 11:54:09 -05:00
|
|
|
virtual bool HasTransparentBackground() { return true; }
|
2004-03-04 12:03:55 -05:00
|
|
|
|
2006-02-12 11:32:50 -05:00
|
|
|
// wxCheckBox-specific processing after processing the update event
|
|
|
|
virtual void DoUpdateWindowUI(wxUpdateUIEvent& event)
|
|
|
|
{
|
2006-06-30 06:51:44 -04:00
|
|
|
wxControl::DoUpdateWindowUI(event);
|
|
|
|
|
2006-02-12 11:32:50 -05:00
|
|
|
if ( event.GetSetChecked() )
|
|
|
|
SetValue(event.GetChecked());
|
|
|
|
}
|
|
|
|
|
2003-09-27 20:23:08 -04:00
|
|
|
protected:
|
2007-11-13 07:10:34 -05:00
|
|
|
// choose the default border for this window
|
|
|
|
virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
|
|
|
|
|
2003-09-27 20:23:08 -04:00
|
|
|
virtual void DoSet3StateValue(wxCheckBoxState WXUNUSED(state)) { wxFAIL; }
|
|
|
|
|
|
|
|
virtual wxCheckBoxState DoGet3StateValue() const
|
|
|
|
{
|
|
|
|
wxFAIL;
|
|
|
|
return wxCHK_UNCHECKED;
|
|
|
|
}
|
2003-07-21 20:24:07 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
DECLARE_NO_COPY_CLASS(wxCheckBoxBase)
|
2001-06-26 16:59:19 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#if defined(__WXUNIVERSAL__)
|
|
|
|
#include "wx/univ/checkbox.h"
|
|
|
|
#elif defined(__WXMSW__)
|
|
|
|
#include "wx/msw/checkbox.h"
|
1998-07-10 10:15:17 -04:00
|
|
|
#elif defined(__WXMOTIF__)
|
2001-06-26 16:59:19 -04:00
|
|
|
#include "wx/motif/checkbox.h"
|
2006-01-22 22:27:34 -05:00
|
|
|
#elif defined(__WXGTK20__)
|
2001-06-26 16:59:19 -04:00
|
|
|
#include "wx/gtk/checkbox.h"
|
2006-01-22 22:27:34 -05:00
|
|
|
#elif defined(__WXGTK__)
|
|
|
|
#include "wx/gtk1/checkbox.h"
|
1998-08-14 20:23:28 -04:00
|
|
|
#elif defined(__WXMAC__)
|
2008-06-11 15:17:41 -04:00
|
|
|
#include "wx/osx/checkbox.h"
|
2003-03-22 01:18:36 -05:00
|
|
|
#elif defined(__WXCOCOA__)
|
|
|
|
#include "wx/cocoa/checkbox.h"
|
1999-07-27 23:38:12 -04:00
|
|
|
#elif defined(__WXPM__)
|
2001-06-26 16:59:19 -04:00
|
|
|
#include "wx/os2/checkbox.h"
|
2005-01-25 01:55:10 -05:00
|
|
|
#elif defined(__WXPALMOS__)
|
|
|
|
#include "wx/palmos/checkbox.h"
|
1998-05-20 10:01:55 -04:00
|
|
|
#endif
|
|
|
|
|
2001-06-26 16:59:19 -04:00
|
|
|
#endif // wxUSE_CHECKBOX
|
|
|
|
|
1998-05-20 10:01:55 -04:00
|
|
|
#endif
|
1998-08-14 20:23:28 -04:00
|
|
|
// _WX_CHECKBOX_H_BASE_
|