2005-03-16 16:18:31 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2011-03-20 00:14:35 +00:00
|
|
|
// Name: wx/statbox.h
|
2005-03-16 16:18:31 +00:00
|
|
|
// Purpose: wxStaticBox base header
|
2005-05-04 18:57:50 +00:00
|
|
|
// Author: Julian Smart
|
2005-03-16 16:18:31 +00:00
|
|
|
// Modified by:
|
|
|
|
// Created:
|
2005-05-04 18:57:50 +00:00
|
|
|
// Copyright: (c) Julian Smart
|
2005-03-16 16:18:31 +00:00
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1998-08-15 00:23:28 +00:00
|
|
|
#ifndef _WX_STATBOX_H_BASE_
|
|
|
|
#define _WX_STATBOX_H_BASE_
|
1998-05-20 14:01:55 +00:00
|
|
|
|
2005-03-16 16:18:31 +00:00
|
|
|
#include "wx/defs.h"
|
|
|
|
|
2001-06-26 20:59:19 +00:00
|
|
|
#if wxUSE_STATBOX
|
|
|
|
|
|
|
|
#include "wx/control.h"
|
2012-09-20 16:00:07 +00:00
|
|
|
#include "wx/containr.h"
|
2001-06-26 20:59:19 +00:00
|
|
|
|
2008-03-26 15:06:00 +00:00
|
|
|
extern WXDLLIMPEXP_DATA_CORE(const char) wxStaticBoxNameStr[];
|
2001-06-26 20:59:19 +00:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxStaticBox: a grouping box with a label
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2012-09-20 16:00:07 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxStaticBoxBase : public wxNavigationEnabled<wxControl>
|
2001-06-26 20:59:19 +00:00
|
|
|
{
|
|
|
|
public:
|
2013-07-31 16:03:51 +00:00
|
|
|
wxStaticBoxBase();
|
2003-07-22 00:24:07 +00:00
|
|
|
|
2011-03-22 14:17:38 +00:00
|
|
|
// overridden base class virtuals
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual bool HasTransparentBackground() wxOVERRIDE { return true; }
|
2018-01-07 00:14:17 +00:00
|
|
|
virtual bool Enable(bool enable = true) wxOVERRIDE;
|
2003-07-22 00:24:07 +00:00
|
|
|
|
2005-03-07 23:37:15 +00:00
|
|
|
// implementation only: this is used by wxStaticBoxSizer to account for the
|
|
|
|
// need for extra space taken by the static box
|
|
|
|
//
|
|
|
|
// the top border is the margin at the top (where the title is),
|
|
|
|
// borderOther is the margin on all other sides
|
2017-12-19 23:06:08 +00:00
|
|
|
virtual void GetBordersForSizer(int *borderTop, int *borderOther) const;
|
2005-03-07 23:37:15 +00:00
|
|
|
|
2017-12-19 20:47:01 +00:00
|
|
|
// This is an internal function currently used by wxStaticBoxSizer only.
|
|
|
|
//
|
|
|
|
// Reparent all children of the static box under its parent and destroy the
|
|
|
|
// box itself.
|
2017-12-19 23:03:55 +00:00
|
|
|
void WXDestroyWithoutChildren();
|
2017-12-19 20:47:01 +00:00
|
|
|
|
2007-12-20 06:08:00 +00:00
|
|
|
protected:
|
2007-11-13 12:10:34 +00:00
|
|
|
// choose the default border for this window
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual wxBorder GetDefaultBorder() const wxOVERRIDE { return wxBORDER_NONE; }
|
2007-11-13 12:10:34 +00:00
|
|
|
|
2017-12-19 23:03:55 +00:00
|
|
|
// If non-null, the window used as our label. This window is owned by the
|
|
|
|
// static box and will be deleted when it is.
|
|
|
|
wxWindow* m_labelWin;
|
|
|
|
|
Don't pretend static box with enabled label is disabled
Trying to be smart by setting m_isEnabled to false in
wxStaticBox::Enable() without actually disabling the box itself (because
it can't be done if its label window is to remain enabled) didn't really
work. For example, it was impossible to TAB to a checkbox label of the
box when it was disabled, because keyboard navigation (correctly)
doesn't recurse into disabled windows and there could be similar
problems with any other code iterating over windows and skipping over
the disabled ones.
So, finally, simplify things and keep m_isEnabled in sync with the real
box state, even if this, counter-intuitively, means that IsEnabled() on
the box returns true after calling Enable(false) on it.
This also reverts 4ee35cf5ee569b6ee6c7d0d5702484d4d2a20f96 ("Don't
disable wxStaticBox children at wx level when disabling it") as we can't
avoid really disabling the children any more now that their parent is
not disabled: without this, their IsEnabled() would return true, i.e.
they wouldn't be disabled at all, from the program point of view. This
is unfortunate for the reasons that originally motivated that commit,
i.e. if some wxStaticBox child is disabled, disabling and re-enabling
the box will now re-enable this child, even if it shouldn't, but seems
impossible to avoid. The only possible alternative is to modify
IsEnabled() to add some wxStaticBox-specific hook to it, e.g. instead of
calling GetParent()->IsEnabled() there, we could call some now
AreChildrenEnable() method, which would delegate to IsEnabled() by
default but overridden in wxStaticBox. However this seems complicated,
and will add an extra virtual function call to all (frequently
happening) IsEnabled() calls.
2018-01-18 22:14:36 +00:00
|
|
|
// For boxes with window label this member variable is used instead of
|
|
|
|
// m_isEnabled to remember the last value passed to Enable(). It is
|
|
|
|
// required because the box itself doesn't get disabled by Enable(false) in
|
|
|
|
// this case (see comments in Enable() implementation), and m_isEnabled
|
|
|
|
// must correspond to its real state.
|
|
|
|
bool m_areChildrenEnabled;
|
|
|
|
|
2009-02-08 11:45:59 +00:00
|
|
|
wxDECLARE_NO_COPY_CLASS(wxStaticBoxBase);
|
2001-06-26 20:59:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#if defined(__WXUNIVERSAL__)
|
2005-01-07 16:54:09 +00:00
|
|
|
#include "wx/univ/statbox.h"
|
2001-06-26 20:59:19 +00:00
|
|
|
#elif defined(__WXMSW__)
|
2005-01-07 16:54:09 +00:00
|
|
|
#include "wx/msw/statbox.h"
|
1998-07-10 14:15:17 +00:00
|
|
|
#elif defined(__WXMOTIF__)
|
2005-01-07 16:54:09 +00:00
|
|
|
#include "wx/motif/statbox.h"
|
2006-01-23 03:27:34 +00:00
|
|
|
#elif defined(__WXGTK20__)
|
2005-01-07 16:54:09 +00:00
|
|
|
#include "wx/gtk/statbox.h"
|
2006-01-23 03:27:34 +00:00
|
|
|
#elif defined(__WXGTK__)
|
|
|
|
#include "wx/gtk1/statbox.h"
|
1998-08-15 00:23:28 +00:00
|
|
|
#elif defined(__WXMAC__)
|
2008-06-11 19:17:41 +00:00
|
|
|
#include "wx/osx/statbox.h"
|
2014-08-24 01:50:11 +00:00
|
|
|
#elif defined(__WXQT__)
|
|
|
|
#include "wx/qt/statbox.h"
|
1998-05-20 14:01:55 +00:00
|
|
|
#endif
|
|
|
|
|
2001-06-26 20:59:19 +00:00
|
|
|
#endif // wxUSE_STATBOX
|
|
|
|
|
1998-05-20 14:01:55 +00:00
|
|
|
#endif
|
1998-08-15 00:23:28 +00:00
|
|
|
// _WX_STATBOX_H_BASE_
|