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