]> git.saurik.com Git - wxWidgets.git/blame - src/msw/statbox.cpp
VTK wrapper of vtkRenderWindow for wxPython. Tested on MSW so far.
[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
2bda0e17 44#if !USE_SHARED_LIBRARY
222594ea 45 IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
2bda0e17
KB
46#endif
47
3f2711d5
VZ
48// ============================================================================
49// implementation
50// ============================================================================
51
52// ----------------------------------------------------------------------------
53// wxStaticBox
54// ----------------------------------------------------------------------------
55
56bool 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)
2bda0e17 63{
3f2711d5
VZ
64 if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) )
65 return FALSE;
2bda0e17 66
222594ea 67 if ( !MSWCreateControl(wxT("BUTTON"), BS_GROUPBOX, pos, size, label, 0) )
3f2711d5 68 return FALSE;
2bda0e17 69
3f2711d5 70 return TRUE;
2bda0e17
KB
71}
72
4438caf4 73wxSize wxStaticBox::DoGetBestSize()
2bda0e17 74{
4438caf4
VZ
75 int cx, cy;
76 wxGetCharSize(GetHWND(), &cx, &cy, &GetFont());
2bda0e17 77
4438caf4
VZ
78 int wBox;
79 GetTextExtent(wxGetWindowText(m_hWnd), &wBox, &cy);
2bda0e17 80
4438caf4
VZ
81 wBox += 3*cx;
82 int hBox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy);
2bda0e17 83
4438caf4
VZ
84 return wxSize(wBox, hBox);
85}
2bda0e17 86
debe6624 87WXHBRUSH wxStaticBox::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
c49245f8
VZ
88 WXUINT message,
89 WXWPARAM wParam,
90 WXLPARAM lParam)
2bda0e17 91{
1f112209 92#if wxUSE_CTL3D
3f2711d5
VZ
93 if ( m_useCtl3D )
94 {
95 HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
96 return (WXHBRUSH) hbrush;
97 }
98#endif // wxUSE_CTL3D
2bda0e17 99
3f2711d5
VZ
100 HDC hdc = (HDC)pDC;
101 if (GetParent()->GetTransparentBackground())
102 SetBkMode(hdc, TRANSPARENT);
103 else
104 SetBkMode(hdc, OPAQUE);
2bda0e17 105
3f2711d5
VZ
106 const wxColour& colBack = GetBackgroundColour();
107 ::SetBkColor(hdc, wxColourToRGB(colBack));
108 ::SetTextColor(hdc, wxColourToRGB(GetForegroundColour()));
2bda0e17 109
07cf98cb 110 wxBrush *brush = wxTheBrushList->FindOrCreateBrush(colBack, wxSOLID);
2bda0e17 111
3f2711d5 112 return (WXHBRUSH)brush->GetResourceHandle();
2bda0e17
KB
113}
114
2bda0e17
KB
115long wxStaticBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
116{
222594ea 117 switch ( nMsg )
1c089c47 118 {
222594ea
VZ
119 case WM_NCHITTEST:
120 // FIXME: this hack is specific to dialog ed, shouldn't it be
121 // somehow disabled during normal operation?
122 {
123 int xPos = LOWORD(lParam); // horizontal position of cursor
124 int yPos = HIWORD(lParam); // vertical position of cursor
125
126 ScreenToClient(&xPos, &yPos);
127
128 // Make sure you can drag by the top of the groupbox, but let
129 // other (enclosed) controls get mouse events also
130 if ( yPos < 10 )
131 return (long)HTCLIENT;
132 }
133 break;
134
135 // VZ: I will remove (or change) this soon... (15.11.99)
136#if 0
137 case WM_ERASEBKGND:
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);
145#endif
1c089c47 146 }
2bda0e17 147
42e69d6b 148 return wxControl::MSWWindowProc(nMsg, wParam, lParam);
2bda0e17
KB
149}
150