]>
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
)
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 if ( !MSWCreateControl(wxT("BUTTON"), BS_GROUPBOX
, pos
, size
, label
, 0) )
73 wxSize
wxStaticBox::DoGetBestSize()
76 wxGetCharSize(GetHWND(), &cx
, &cy
, &GetFont());
79 GetTextExtent(wxGetWindowText(m_hWnd
), &wBox
, &cy
);
82 int hBox
= EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy
);
84 return wxSize(wBox
, hBox
);
87 WXHBRUSH
wxStaticBox::OnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
95 HBRUSH hbrush
= Ctl3dCtlColorEx(message
, wParam
, lParam
);
96 return (WXHBRUSH
) hbrush
;
101 if (GetParent()->GetTransparentBackground())
102 SetBkMode(hdc
, TRANSPARENT
);
104 SetBkMode(hdc
, OPAQUE
);
106 const wxColour
& colBack
= GetBackgroundColour();
107 ::SetBkColor(hdc
, wxColourToRGB(colBack
));
108 ::SetTextColor(hdc
, wxColourToRGB(GetForegroundColour()));
110 wxBrush
*brush
= wxTheBrushList
->FindOrCreateBrush(colBack
, wxSOLID
);
112 return (WXHBRUSH
)brush
->GetResourceHandle();
115 long wxStaticBox::MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
)
120 // FIXME: this hack is specific to dialog ed, shouldn't it be
121 // somehow disabled during normal operation?
123 int xPos
= LOWORD(lParam
); // horizontal position of cursor
124 int yPos
= HIWORD(lParam
); // vertical position of cursor
126 ScreenToClient(&xPos
, &yPos
);
128 // Make sure you can drag by the top of the groupbox, but let
129 // other (enclosed) controls get mouse events also
131 return (long)HTCLIENT
;
135 // VZ: I will remove (or change) this soon... (15.11.99)
138 // prevent wxControl from processing this message because it will
139 // erase the background incorrectly and there is no way for us to
140 // override this at wxWin event level (if we do process the event,
141 // we don't know how to do it properly - paint the background
142 // without painting over other controls - and if we don't,
143 // wxControl still gets it)
144 return MSWDefWindowProc(nMsg
, wParam
, lParam
);
148 return wxControl::MSWWindowProc(nMsg
, wParam
, lParam
);