2001-06-26 20:59:19 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/checkbox.h
|
|
|
|
// Purpose: wxCheckBox class interface
|
|
|
|
// Author: Vadim Zeitlin
|
|
|
|
// Modified by:
|
|
|
|
// Created: 07.09.00
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) wxWindows team
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1998-08-15 00:23:28 +00:00
|
|
|
#ifndef _WX_CHECKBOX_H_BASE_
|
|
|
|
#define _WX_CHECKBOX_H_BASE_
|
1998-05-20 14:01:55 +00:00
|
|
|
|
2003-07-09 21:48:53 +00:00
|
|
|
#include "wx/defs.h"
|
|
|
|
|
2001-06-26 20:59:19 +00:00
|
|
|
#if wxUSE_CHECKBOX
|
|
|
|
|
|
|
|
#include "wx/control.h"
|
|
|
|
|
2003-09-28 00:23:08 +00: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 */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
WXDLLEXPORT_DATA(extern const wxChar *) wxCheckBoxNameStr;
|
2001-06-26 20:59:19 +00:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxCheckBox: a control which shows a label and a box which may be checked
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxCheckBoxBase : public wxControl
|
|
|
|
{
|
|
|
|
public:
|
2004-01-15 13:49:22 +00:00
|
|
|
wxCheckBoxBase() { }
|
2003-07-22 00:24:07 +00:00
|
|
|
|
2001-06-26 20:59:19 +00:00
|
|
|
// set/get the checked status of the listbox
|
2003-09-28 18:01:42 +00:00
|
|
|
virtual void SetValue(bool value) = 0;
|
2001-06-26 20:59:19 +00:00
|
|
|
virtual bool GetValue() const = 0;
|
|
|
|
|
2003-09-28 00:23:08 +00: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 22:45:23 +00:00
|
|
|
bool Is3State() const { return HasFlag(wxCHK_3STATE); }
|
2003-09-28 00:23:08 +00:00
|
|
|
|
|
|
|
bool Is3rdStateAllowedForUser() const
|
|
|
|
{
|
2003-10-15 22:45:23 +00:00
|
|
|
return HasFlag(wxCHK_ALLOW_3RD_STATE_FOR_USER);
|
2003-09-28 00:23:08 +00:00
|
|
|
}
|
|
|
|
|
2004-03-05 05:28:21 +00:00
|
|
|
virtual void ApplyParentThemeBackground(const wxColour& bg)
|
|
|
|
{ SetBackgroundColour(bg); }
|
2004-03-04 17:03:55 +00:00
|
|
|
|
2003-09-28 00:23:08 +00:00
|
|
|
protected:
|
|
|
|
virtual void DoSet3StateValue(wxCheckBoxState WXUNUSED(state)) { wxFAIL; }
|
|
|
|
|
|
|
|
virtual wxCheckBoxState DoGet3StateValue() const
|
|
|
|
{
|
|
|
|
wxFAIL;
|
|
|
|
return wxCHK_UNCHECKED;
|
|
|
|
}
|
2003-07-22 00:24:07 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
DECLARE_NO_COPY_CLASS(wxCheckBoxBase)
|
2001-06-26 20:59:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#if defined(__WXUNIVERSAL__)
|
|
|
|
#include "wx/univ/checkbox.h"
|
|
|
|
#elif defined(__WXMSW__)
|
|
|
|
#include "wx/msw/checkbox.h"
|
1998-07-10 14:15:17 +00:00
|
|
|
#elif defined(__WXMOTIF__)
|
2001-06-26 20:59:19 +00:00
|
|
|
#include "wx/motif/checkbox.h"
|
1998-07-10 14:15:17 +00:00
|
|
|
#elif defined(__WXGTK__)
|
2001-06-26 20:59:19 +00:00
|
|
|
#include "wx/gtk/checkbox.h"
|
1998-08-15 00:23:28 +00:00
|
|
|
#elif defined(__WXMAC__)
|
2001-06-26 20:59:19 +00:00
|
|
|
#include "wx/mac/checkbox.h"
|
2003-03-22 06:18:36 +00:00
|
|
|
#elif defined(__WXCOCOA__)
|
|
|
|
#include "wx/cocoa/checkbox.h"
|
1999-07-28 03:38:12 +00:00
|
|
|
#elif defined(__WXPM__)
|
2001-06-26 20:59:19 +00:00
|
|
|
#include "wx/os2/checkbox.h"
|
1998-05-20 14:01:55 +00:00
|
|
|
#endif
|
|
|
|
|
2001-06-26 20:59:19 +00:00
|
|
|
#endif // wxUSE_CHECKBOX
|
|
|
|
|
1998-05-20 14:01:55 +00:00
|
|
|
#endif
|
1998-08-15 00:23:28 +00:00
|
|
|
// _WX_CHECKBOX_H_BASE_
|