]>
Commit | Line | Data |
---|---|---|
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$ | |
6c9a19aa JS |
8 | // Copyright: (c) Julian Smart |
9 | // Licence: wxWindows licence | |
2bda0e17 KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
3f2711d5 VZ |
12 | // ============================================================================ |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
14f355c2 | 20 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
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 | ||
1e6feb95 VZ |
31 | #if wxUSE_STATBOX |
32 | ||
2bda0e17 | 33 | #ifndef WX_PRECOMP |
3f2711d5 VZ |
34 | #include "wx/app.h" |
35 | #include "wx/dcclient.h" | |
2bda0e17 KB |
36 | #endif |
37 | ||
38 | #include "wx/statbox.h" | |
2bda0e17 | 39 | |
3f2711d5 VZ |
40 | #include "wx/msw/private.h" |
41 | ||
42 | // ---------------------------------------------------------------------------- | |
43 | // wxWin macros | |
44 | // ---------------------------------------------------------------------------- | |
45 | ||
5bd3a2da | 46 | IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl) |
066f1b7a SC |
47 | /* |
48 | TODO PROPERTIES : | |
49 | label | |
50 | */ | |
2bda0e17 | 51 | |
3f2711d5 VZ |
52 | // ============================================================================ |
53 | // implementation | |
54 | // ============================================================================ | |
55 | ||
56 | // ---------------------------------------------------------------------------- | |
57 | // wxStaticBox | |
58 | // ---------------------------------------------------------------------------- | |
59 | ||
60 | bool wxStaticBox::Create(wxWindow *parent, | |
61 | wxWindowID id, | |
62 | const wxString& label, | |
63 | const wxPoint& pos, | |
64 | const wxSize& size, | |
65 | long style, | |
66 | const wxString& name) | |
2bda0e17 | 67 | { |
11b6a93b | 68 | if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) ) |
3f2711d5 | 69 | return FALSE; |
2bda0e17 | 70 | |
48c1b6f9 VZ |
71 | // as wxStaticBox doesn't draw its own background, we make it transparent |
72 | // to force redrawing its background which could have been overwritten by | |
73 | // the other controls inside it | |
74 | // | |
75 | // FIXME: I still think that it isn't the right solution because the static | |
76 | // boxes shouldn't have to be transparent if the redrawing was done | |
77 | // right elsewhere - who ever had to make them transparent in non | |
78 | // wxWindows programs, after all? But for now it does fix a serious | |
79 | // problem (try resizing the sizers test screen in the layout sample | |
80 | // after removing WS_EX_TRANSPARENT bit) and so let's use it until | |
81 | // we fix the real underlying problem | |
82 | if ( !MSWCreateControl(wxT("BUTTON"), BS_GROUPBOX, pos, size, label, | |
4676948b JS |
83 | #ifdef __WXWINCE__ |
84 | 0 | |
85 | #else | |
86 | WS_EX_TRANSPARENT | |
87 | #endif | |
88 | ) ) | |
3f2711d5 | 89 | return FALSE; |
2bda0e17 | 90 | |
92b0a2a1 VZ |
91 | // to be transparent we should have the same colour as the parent as well |
92 | SetBackgroundColour(GetParent()->GetBackgroundColour()); | |
93 | ||
3f2711d5 | 94 | return TRUE; |
2bda0e17 KB |
95 | } |
96 | ||
f68586e5 | 97 | wxSize wxStaticBox::DoGetBestSize() const |
2bda0e17 | 98 | { |
4438caf4 VZ |
99 | int cx, cy; |
100 | wxGetCharSize(GetHWND(), &cx, &cy, &GetFont()); | |
2bda0e17 | 101 | |
4438caf4 VZ |
102 | int wBox; |
103 | GetTextExtent(wxGetWindowText(m_hWnd), &wBox, &cy); | |
2bda0e17 | 104 | |
4438caf4 VZ |
105 | wBox += 3*cx; |
106 | int hBox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy); | |
2bda0e17 | 107 | |
4438caf4 VZ |
108 | return wxSize(wBox, hBox); |
109 | } | |
2bda0e17 | 110 | |
2bda0e17 KB |
111 | long wxStaticBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) |
112 | { | |
222594ea | 113 | switch ( nMsg ) |
1c089c47 | 114 | { |
4676948b | 115 | #ifndef __WXWINCE__ |
222594ea VZ |
116 | case WM_NCHITTEST: |
117 | // FIXME: this hack is specific to dialog ed, shouldn't it be | |
118 | // somehow disabled during normal operation? | |
119 | { | |
120 | int xPos = LOWORD(lParam); // horizontal position of cursor | |
121 | int yPos = HIWORD(lParam); // vertical position of cursor | |
122 | ||
123 | ScreenToClient(&xPos, &yPos); | |
124 | ||
125 | // Make sure you can drag by the top of the groupbox, but let | |
126 | // other (enclosed) controls get mouse events also | |
127 | if ( yPos < 10 ) | |
128 | return (long)HTCLIENT; | |
129 | } | |
130 | break; | |
4676948b | 131 | #endif |
222594ea VZ |
132 | case WM_ERASEBKGND: |
133 | // prevent wxControl from processing this message because it will | |
134 | // erase the background incorrectly and there is no way for us to | |
135 | // override this at wxWin event level (if we do process the event, | |
136 | // we don't know how to do it properly - paint the background | |
137 | // without painting over other controls - and if we don't, | |
138 | // wxControl still gets it) | |
139 | return MSWDefWindowProc(nMsg, wParam, lParam); | |
1c089c47 | 140 | } |
2bda0e17 | 141 | |
42e69d6b | 142 | return wxControl::MSWWindowProc(nMsg, wParam, lParam); |
2bda0e17 KB |
143 | } |
144 | ||
1e6feb95 | 145 | #endif // wxUSE_STATBOX |