]> git.saurik.com Git - wxWidgets.git/blame - src/msw/statbox.cpp
fixed wxListCtrl::EditLabel for MSW (ListView_EditLabel fails if
[wxWidgets.git] / src / msw / statbox.cpp
CommitLineData
2bda0e17 1/////////////////////////////////////////////////////////////////////////////
3f2711d5 2// Name: msw/statbox.cpp
2bda0e17
KB
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
c49245f8 9// Licence: wxWindows license
2bda0e17
KB
10/////////////////////////////////////////////////////////////////////////////
11
3f2711d5
VZ
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
2bda0e17 20#ifdef __GNUG__
3f2711d5 21 #pragma implementation "statbox.h"
2bda0e17
KB
22#endif
23
24// For compilers that support precompilation, includes "wx.h".
25#include "wx/wxprec.h"
26
27#ifdef __BORLANDC__
3f2711d5 28 #pragma hdrstop
2bda0e17
KB
29#endif
30
31#ifndef WX_PRECOMP
3f2711d5
VZ
32 #include "wx/app.h"
33 #include "wx/dcclient.h"
2bda0e17
KB
34#endif
35
36#include "wx/statbox.h"
2bda0e17 37
3f2711d5
VZ
38#include "wx/msw/private.h"
39
40// ----------------------------------------------------------------------------
41// wxWin macros
42// ----------------------------------------------------------------------------
43
5bd3a2da 44IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
2bda0e17 45
3f2711d5
VZ
46// ============================================================================
47// implementation
48// ============================================================================
49
50// ----------------------------------------------------------------------------
51// wxStaticBox
52// ----------------------------------------------------------------------------
53
54bool 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)
2bda0e17 61{
11b6a93b 62 if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) )
3f2711d5 63 return FALSE;
2bda0e17 64
222594ea 65 if ( !MSWCreateControl(wxT("BUTTON"), BS_GROUPBOX, pos, size, label, 0) )
3f2711d5 66 return FALSE;
2bda0e17 67
3f2711d5 68 return TRUE;
2bda0e17
KB
69}
70
f68586e5 71wxSize wxStaticBox::DoGetBestSize() const
2bda0e17 72{
4438caf4
VZ
73 int cx, cy;
74 wxGetCharSize(GetHWND(), &cx, &cy, &GetFont());
2bda0e17 75
4438caf4
VZ
76 int wBox;
77 GetTextExtent(wxGetWindowText(m_hWnd), &wBox, &cy);
2bda0e17 78
4438caf4
VZ
79 wBox += 3*cx;
80 int hBox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy);
2bda0e17 81
4438caf4
VZ
82 return wxSize(wBox, hBox);
83}
2bda0e17 84
2bda0e17
KB
85long wxStaticBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
86{
222594ea 87 switch ( nMsg )
1c089c47 88 {
222594ea
VZ
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
222594ea
VZ
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);
1c089c47 113 }
2bda0e17 114
42e69d6b 115 return wxControl::MSWWindowProc(nMsg, wParam, lParam);
2bda0e17
KB
116}
117