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 */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
WXDLLEXPORT_DATA(extern const wxChar *) wxCheckBoxNameStr;
|
2001-06-26 16:59:19 -04:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxCheckBox: a control which shows a label and a box which may be checked
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxCheckBoxBase : public wxControl
|
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2004-03-05 00:28:21 -05:00
|
|
|
virtual void ApplyParentThemeBackground(const wxColour& bg)
|
|
|
|
{ SetBackgroundColour(bg); }
|
2004-03-04 12:03:55 -05:00
|
|
|
|
2003-09-27 20:23:08 -04:00
|
|
|
protected:
|
|
|
|
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"
|
1998-07-10 10:15:17 -04:00
|
|
|
#elif defined(__WXGTK__)
|
2001-06-26 16:59:19 -04:00
|
|
|
#include "wx/gtk/checkbox.h"
|
1998-08-14 20:23:28 -04:00
|
|
|
#elif defined(__WXMAC__)
|
2001-06-26 16:59:19 -04:00
|
|
|
#include "wx/mac/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"
|
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_
|