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