]>
git.saurik.com Git - wxWidgets.git/blob - src/msw/statbox.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: msw/statbox.cpp
3 // Purpose: wxStaticBox
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "statbox.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
35 #include "wx/dcclient.h"
38 #include "wx/statbox.h"
40 #include "wx/msw/private.h"
42 // ----------------------------------------------------------------------------
44 // ----------------------------------------------------------------------------
46 #if wxUSE_EXTENDED_RTTI
47 IMPLEMENT_DYNAMIC_CLASS_XTI(wxStaticBox
, wxControl
,"wx/statbox.h")
49 WX_BEGIN_PROPERTIES_TABLE(wxStaticBox
)
50 WX_PROPERTY( Label
,wxString
, SetLabel
, GetLabel
, wxT("") )
55 WX_END_PROPERTIES_TABLE()
57 WX_BEGIN_HANDLERS_TABLE(wxStaticBox
)
58 WX_END_HANDLERS_TABLE()
60 WX_CONSTRUCTOR_6( wxStaticBox
, wxWindow
* , Parent
, wxWindowID
, Id
, wxString
, Label
, wxPoint
, Position
, wxSize
, Size
, long , WindowStyle
)
62 IMPLEMENT_DYNAMIC_CLASS(wxStaticBox
, wxControl
)
65 // ============================================================================
67 // ============================================================================
69 // ----------------------------------------------------------------------------
71 // ----------------------------------------------------------------------------
73 bool wxStaticBox::Create(wxWindow
*parent
,
75 const wxString
& label
,
81 if ( !CreateControl(parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
) )
84 // as wxStaticBox doesn't draw its own background, we make it transparent
85 // to force redrawing its background which could have been overwritten by
86 // the other controls inside it
88 // FIXME: I still think that it isn't the right solution because the static
89 // boxes shouldn't have to be transparent if the redrawing was done
90 // right elsewhere - who ever had to make them transparent in non
91 // wxWindows programs, after all? But for now it does fix a serious
92 // problem (try resizing the sizers test screen in the layout sample
93 // after removing WS_EX_TRANSPARENT bit) and so let's use it until
94 // we fix the real underlying problem
95 if ( !MSWCreateControl(wxT("BUTTON"), BS_GROUPBOX
, pos
, size
, label
,
104 // to be transparent we should have the same colour as the parent as well
105 SetBackgroundColour(GetParent()->GetBackgroundColour());
110 wxSize
wxStaticBox::DoGetBestSize() const
113 wxGetCharSize(GetHWND(), &cx
, &cy
, &GetFont());
116 GetTextExtent(wxGetWindowText(m_hWnd
), &wBox
, &cy
);
119 int hBox
= EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy
);
121 return wxSize(wBox
, hBox
);
124 long wxStaticBox::MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
)
130 // FIXME: this hack is specific to dialog ed, shouldn't it be
131 // somehow disabled during normal operation?
133 int xPos
= LOWORD(lParam
); // horizontal position of cursor
134 int yPos
= HIWORD(lParam
); // vertical position of cursor
136 ScreenToClient(&xPos
, &yPos
);
138 // Make sure you can drag by the top of the groupbox, but let
139 // other (enclosed) controls get mouse events also
141 return (long)HTCLIENT
;
146 // prevent wxControl from processing this message because it will
147 // erase the background incorrectly and there is no way for us to
148 // override this at wxWin event level (if we do process the event,
149 // we don't know how to do it properly - paint the background
150 // without painting over other controls - and if we don't,
151 // wxControl still gets it)
152 return MSWDefWindowProc(nMsg
, wParam
, lParam
);
155 return wxControl::MSWWindowProc(nMsg
, wParam
, lParam
);
158 #endif // wxUSE_STATBOX