]> git.saurik.com Git - wxWidgets.git/blob - src/msw/statbox.cpp
Fixed precedence order problem for IsShiftDown and IsCtrlDown. (It
[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 IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
45
46 // ============================================================================
47 // implementation
48 // ============================================================================
49
50 // ----------------------------------------------------------------------------
51 // wxStaticBox
52 // ----------------------------------------------------------------------------
53
54 bool wxStaticBox::Create(wxWindow *parent,
55 wxWindowID id,
56 const wxString& label,
57 const wxPoint& pos,
58 const wxSize& size,
59 long style,
60 const wxString& name)
61 {
62 if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) )
63 return FALSE;
64
65 if ( !MSWCreateControl(wxT("BUTTON"), BS_GROUPBOX, pos, size, label, 0) )
66 return FALSE;
67
68 return TRUE;
69 }
70
71 wxSize wxStaticBox::DoGetBestSize() const
72 {
73 int cx, cy;
74 wxGetCharSize(GetHWND(), &cx, &cy, &GetFont());
75
76 int wBox;
77 GetTextExtent(wxGetWindowText(m_hWnd), &wBox, &cy);
78
79 wBox += 3*cx;
80 int hBox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy);
81
82 return wxSize(wBox, hBox);
83 }
84
85 long wxStaticBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
86 {
87 switch ( nMsg )
88 {
89 case WM_NCHITTEST:
90 // FIXME: this hack is specific to dialog ed, shouldn't it be
91 // somehow disabled during normal operation?
92 {
93 int xPos = LOWORD(lParam); // horizontal position of cursor
94 int yPos = HIWORD(lParam); // vertical position of cursor
95
96 ScreenToClient(&xPos, &yPos);
97
98 // Make sure you can drag by the top of the groupbox, but let
99 // other (enclosed) controls get mouse events also
100 if ( yPos < 10 )
101 return (long)HTCLIENT;
102 }
103 break;
104
105 case WM_ERASEBKGND:
106 // prevent wxControl from processing this message because it will
107 // erase the background incorrectly and there is no way for us to
108 // override this at wxWin event level (if we do process the event,
109 // we don't know how to do it properly - paint the background
110 // without painting over other controls - and if we don't,
111 // wxControl still gets it)
112 return MSWDefWindowProc(nMsg, wParam, lParam);
113 }
114
115 return wxControl::MSWWindowProc(nMsg, wParam, lParam);
116 }
117