]>
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"
33 #include "wx/dcclient.h"
36 #include "wx/statbox.h"
38 #include "wx/msw/private.h"
40 // ----------------------------------------------------------------------------
42 // ----------------------------------------------------------------------------
44 #if !USE_SHARED_LIBRARY
45 IMPLEMENT_DYNAMIC_CLASS(wxStaticBox
, wxControl
)
47 BEGIN_EVENT_TABLE(wxStaticBox
, wxControl
)
48 EVT_ERASE_BACKGROUND(wxStaticBox::OnEraseBackground
)
53 // ============================================================================
55 // ============================================================================
57 // ----------------------------------------------------------------------------
59 // ----------------------------------------------------------------------------
61 bool wxStaticBox::Create(wxWindow
*parent
,
63 const wxString
& label
,
69 if ( !CreateControl(parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
) )
72 if ( !MSWCreateControl(wxT("BUTTON"), BS_GROUPBOX
) )
75 SetSize(pos
.x
, pos
.y
, size
.x
, size
.y
);
80 wxSize
wxStaticBox::DoGetBestSize()
83 wxGetCharSize(GetHWND(), &cx
, &cy
, &GetFont());
86 GetTextExtent(wxGetWindowText(m_hWnd
), &wBox
, &cy
);
89 int hBox
= EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy
);
91 return wxSize(wBox
, hBox
);
94 WXHBRUSH
wxStaticBox::OnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
102 HBRUSH hbrush
= Ctl3dCtlColorEx(message
, wParam
, lParam
);
103 return (WXHBRUSH
) hbrush
;
105 #endif // wxUSE_CTL3D
108 if (GetParent()->GetTransparentBackground())
109 SetBkMode(hdc
, TRANSPARENT
);
111 SetBkMode(hdc
, OPAQUE
);
113 const wxColour
& colBack
= GetBackgroundColour();
114 ::SetBkColor(hdc
, wxColourToRGB(colBack
));
115 ::SetTextColor(hdc
, wxColourToRGB(GetForegroundColour()));
117 wxBrush
*brush
= wxTheBrushList
->FindOrCreateBrush(colBack
, wxSOLID
);
119 return (WXHBRUSH
)brush
->GetResourceHandle();
122 void wxStaticBox::OnEraseBackground(wxEraseEvent
& event
)
124 // do nothing - the aim of having this function is to prevent
125 // wxControl::OnEraseBackground() to paint over the control inside the
129 long wxStaticBox::MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
)
131 if ( nMsg
== WM_NCHITTEST
)
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
;
144 return wxControl::MSWWindowProc(nMsg
, wParam
, lParam
);