]>
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 and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
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 IMPLEMENT_DYNAMIC_CLASS(wxStaticBox
, wxControl
)
48 // ============================================================================
50 // ============================================================================
52 // ----------------------------------------------------------------------------
54 // ----------------------------------------------------------------------------
56 bool wxStaticBox::Create(wxWindow
*parent
,
58 const wxString
& label
,
64 if ( !CreateControl(parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
) )
67 // as wxStaticBox doesn't draw its own background, we make it transparent
68 // to force redrawing its background which could have been overwritten by
69 // the other controls inside it
71 // FIXME: I still think that it isn't the right solution because the static
72 // boxes shouldn't have to be transparent if the redrawing was done
73 // right elsewhere - who ever had to make them transparent in non
74 // wxWindows programs, after all? But for now it does fix a serious
75 // problem (try resizing the sizers test screen in the layout sample
76 // after removing WS_EX_TRANSPARENT bit) and so let's use it until
77 // we fix the real underlying problem
78 if ( !MSWCreateControl(wxT("BUTTON"), BS_GROUPBOX
, pos
, size
, label
,
85 wxSize
wxStaticBox::DoGetBestSize() const
88 wxGetCharSize(GetHWND(), &cx
, &cy
, &GetFont());
91 GetTextExtent(wxGetWindowText(m_hWnd
), &wBox
, &cy
);
94 int hBox
= EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy
);
96 return wxSize(wBox
, hBox
);
99 long wxStaticBox::MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
)
104 // FIXME: this hack is specific to dialog ed, shouldn't it be
105 // somehow disabled during normal operation?
107 int xPos
= LOWORD(lParam
); // horizontal position of cursor
108 int yPos
= HIWORD(lParam
); // vertical position of cursor
110 ScreenToClient(&xPos
, &yPos
);
112 // Make sure you can drag by the top of the groupbox, but let
113 // other (enclosed) controls get mouse events also
115 return (long)HTCLIENT
;
120 // prevent wxControl from processing this message because it will
121 // erase the background incorrectly and there is no way for us to
122 // override this at wxWin event level (if we do process the event,
123 // we don't know how to do it properly - paint the background
124 // without painting over other controls - and if we don't,
125 // wxControl still gets it)
126 return MSWDefWindowProc(nMsg
, wParam
, lParam
);
129 return wxControl::MSWWindowProc(nMsg
, wParam
, lParam
);
132 #endif // wxUSE_STATBOX