1. wxMDIParentFrame::~wxMDIParentFrame() bug fixed
[wxWidgets.git] / src / msw / statbox.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: msw/statbox.cpp
3 // Purpose: wxStaticBox
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 04/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #ifdef __GNUG__
21 #pragma implementation "statbox.h"
22 #endif
23
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
26
27 #ifdef __BORLANDC__
28 #pragma hdrstop
29 #endif
30
31 #ifndef WX_PRECOMP
32 #include "wx/app.h"
33 #include "wx/dcclient.h"
34 #endif
35
36 #include "wx/statbox.h"
37
38 #include "wx/msw/private.h"
39
40 // ----------------------------------------------------------------------------
41 // wxWin macros
42 // ----------------------------------------------------------------------------
43
44 #if !USE_SHARED_LIBRARY
45 IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
46 #endif
47
48 // ============================================================================
49 // implementation
50 // ============================================================================
51
52 // ----------------------------------------------------------------------------
53 // wxStaticBox
54 // ----------------------------------------------------------------------------
55
56 bool wxStaticBox::Create(wxWindow *parent,
57 wxWindowID id,
58 const wxString& label,
59 const wxPoint& pos,
60 const wxSize& size,
61 long style,
62 const wxString& name)
63 {
64 if ( !CreateControl(parent, id, pos, size, style, name) )
65 return FALSE;
66
67 if ( !MSWCreateControl(wxT("BUTTON"), BS_GROUPBOX, pos, size, label, 0) )
68 return FALSE;
69
70 return TRUE;
71 }
72
73 wxSize wxStaticBox::DoGetBestSize() const
74 {
75 int cx, cy;
76 wxGetCharSize(GetHWND(), &cx, &cy, &GetFont());
77
78 int wBox;
79 GetTextExtent(wxGetWindowText(m_hWnd), &wBox, &cy);
80
81 wBox += 3*cx;
82 int hBox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy);
83
84 return wxSize(wBox, hBox);
85 }
86
87 long wxStaticBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
88 {
89 switch ( nMsg )
90 {
91 case WM_NCHITTEST:
92 // FIXME: this hack is specific to dialog ed, shouldn't it be
93 // somehow disabled during normal operation?
94 {
95 int xPos = LOWORD(lParam); // horizontal position of cursor
96 int yPos = HIWORD(lParam); // vertical position of cursor
97
98 ScreenToClient(&xPos, &yPos);
99
100 // Make sure you can drag by the top of the groupbox, but let
101 // other (enclosed) controls get mouse events also
102 if ( yPos < 10 )
103 return (long)HTCLIENT;
104 }
105 break;
106
107 // VZ: I will remove (or change) this soon... (15.11.99)
108 #if 0
109 case WM_ERASEBKGND:
110 // prevent wxControl from processing this message because it will
111 // erase the background incorrectly and there is no way for us to
112 // override this at wxWin event level (if we do process the event,
113 // we don't know how to do it properly - paint the background
114 // without painting over other controls - and if we don't,
115 // wxControl still gets it)
116 return MSWDefWindowProc(nMsg, wParam, lParam);
117 #endif
118 }
119
120 return wxControl::MSWWindowProc(nMsg, wParam, lParam);
121 }
122