Inherit from wxCompositeWindowSettersOnly<> to make sure all the usual setters, such as SetForegroundColour() and SetFont(), called on wxStaticBox are propagated to the label window too. However also prevent SetBackgroundColour() from being propagated unnecessarily -- because the checkbox already inherits the parent background colour by default in wxMSW anyhow -- and still override SetFont() to adjust the label window position after the font change, otherwise it could be truncated after increasing the font size, for example. Because of these issues, wxCompositeWindowSettersOnly is not ideally suited for its use here, but on balance it still seems to be better to use it rather than reimplement parts of its functionality here.
106 lines
3.6 KiB
C++
106 lines
3.6 KiB
C++
/////////////////////////////////////////////////////////////////////////////
|
|
// Name: wx/msw/statbox.h
|
|
// Purpose: wxStaticBox class
|
|
// Author: Julian Smart
|
|
// Modified by:
|
|
// Created: 01/02/97
|
|
// Copyright: (c) Julian Smart
|
|
// Licence: wxWindows licence
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
#ifndef _WX_MSW_STATBOX_H_
|
|
#define _WX_MSW_STATBOX_H_
|
|
|
|
#include "wx/compositewin.h"
|
|
|
|
// Group box
|
|
class WXDLLIMPEXP_CORE wxStaticBox : public wxCompositeWindowSettersOnly<wxStaticBoxBase>
|
|
{
|
|
public:
|
|
wxStaticBox()
|
|
: wxCompositeWindowSettersOnly<wxStaticBoxBase>()
|
|
{
|
|
}
|
|
|
|
wxStaticBox(wxWindow *parent, wxWindowID id,
|
|
const wxString& label,
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
const wxSize& size = wxDefaultSize,
|
|
long style = 0,
|
|
const wxString& name = wxStaticBoxNameStr)
|
|
: wxCompositeWindowSettersOnly<wxStaticBoxBase>()
|
|
{
|
|
Create(parent, id, label, pos, size, style, name);
|
|
}
|
|
|
|
wxStaticBox(wxWindow* parent, wxWindowID id,
|
|
wxWindow* label,
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
const wxSize& size = wxDefaultSize,
|
|
long style = 0,
|
|
const wxString &name = wxStaticBoxNameStr)
|
|
: wxCompositeWindowSettersOnly<wxStaticBoxBase>()
|
|
{
|
|
Create(parent, id, label, pos, size, style, name);
|
|
}
|
|
|
|
bool Create(wxWindow *parent, wxWindowID id,
|
|
const wxString& label,
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
const wxSize& size = wxDefaultSize,
|
|
long style = 0,
|
|
const wxString& name = wxStaticBoxNameStr);
|
|
|
|
bool Create(wxWindow *parent, wxWindowID id,
|
|
wxWindow* label,
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
const wxSize& size = wxDefaultSize,
|
|
long style = 0,
|
|
const wxString& name = wxStaticBoxNameStr);
|
|
|
|
/// Implementation only
|
|
virtual void GetBordersForSizer(int *borderTop, int *borderOther) const wxOVERRIDE;
|
|
|
|
virtual bool SetBackgroundColour(const wxColour& colour) wxOVERRIDE;
|
|
virtual bool SetFont(const wxFont& font) wxOVERRIDE;
|
|
|
|
virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const wxOVERRIDE;
|
|
|
|
// returns true if the platform should explicitly apply a theme border
|
|
virtual bool CanApplyThemeBorder() const wxOVERRIDE { return false; }
|
|
|
|
protected:
|
|
virtual wxSize DoGetBestSize() const wxOVERRIDE;
|
|
|
|
public:
|
|
virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) wxOVERRIDE;
|
|
|
|
protected:
|
|
virtual wxWindowList GetCompositeWindowParts() const wxOVERRIDE;
|
|
|
|
// return the region with all the windows inside this static box excluded
|
|
virtual WXHRGN MSWGetRegionWithoutChildren();
|
|
|
|
// remove the parts which are painted by static box itself from the given
|
|
// region which is embedded in a rectangle (0, 0)-(w, h)
|
|
virtual void MSWGetRegionWithoutSelf(WXHRGN hrgn, int w, int h);
|
|
|
|
// paint the given rectangle with our background brush/colour
|
|
virtual void PaintBackground(wxDC& dc, const struct tagRECT& rc);
|
|
// paint the foreground of the static box
|
|
virtual void PaintForeground(wxDC& dc, const struct tagRECT& rc);
|
|
|
|
void OnPaint(wxPaintEvent& event);
|
|
|
|
private:
|
|
void PositionLabelWindow();
|
|
|
|
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxStaticBox);
|
|
};
|
|
|
|
// Indicate that we have the ctor overload taking wxWindow as label.
|
|
#define wxHAS_WINDOW_LABEL_IN_STATIC_BOX
|
|
|
|
#endif // _WX_MSW_STATBOX_H_
|
|
|