]>
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 | 8 | // Copyright: (c) Julian Smart |
65571936 | 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" | |
3ad70d31 | 39 | #include "wx/notebook.h" |
2bda0e17 | 40 | |
3f2711d5 VZ |
41 | #include "wx/msw/private.h" |
42 | ||
301e257b VZ |
43 | // this is for Win CE |
44 | #ifndef WS_EX_TRANSPARENT | |
45 | #define WS_EX_TRANSPARENT 0 | |
46 | #endif | |
47 | ||
3f2711d5 VZ |
48 | // ---------------------------------------------------------------------------- |
49 | // wxWin macros | |
50 | // ---------------------------------------------------------------------------- | |
51 | ||
51741307 | 52 | #if wxUSE_EXTENDED_RTTI |
bc9fb572 JS |
53 | WX_DEFINE_FLAGS( wxStaticBoxStyle ) |
54 | ||
3ff066a4 | 55 | wxBEGIN_FLAGS( wxStaticBoxStyle ) |
bc9fb572 JS |
56 | // new style border flags, we put them first to |
57 | // use them for streaming out | |
3ff066a4 SC |
58 | wxFLAGS_MEMBER(wxBORDER_SIMPLE) |
59 | wxFLAGS_MEMBER(wxBORDER_SUNKEN) | |
60 | wxFLAGS_MEMBER(wxBORDER_DOUBLE) | |
61 | wxFLAGS_MEMBER(wxBORDER_RAISED) | |
62 | wxFLAGS_MEMBER(wxBORDER_STATIC) | |
63 | wxFLAGS_MEMBER(wxBORDER_NONE) | |
57f4f925 | 64 | |
bc9fb572 | 65 | // old style border flags |
3ff066a4 SC |
66 | wxFLAGS_MEMBER(wxSIMPLE_BORDER) |
67 | wxFLAGS_MEMBER(wxSUNKEN_BORDER) | |
68 | wxFLAGS_MEMBER(wxDOUBLE_BORDER) | |
69 | wxFLAGS_MEMBER(wxRAISED_BORDER) | |
70 | wxFLAGS_MEMBER(wxSTATIC_BORDER) | |
cb0afb26 | 71 | wxFLAGS_MEMBER(wxBORDER) |
bc9fb572 JS |
72 | |
73 | // standard window styles | |
3ff066a4 SC |
74 | wxFLAGS_MEMBER(wxTAB_TRAVERSAL) |
75 | wxFLAGS_MEMBER(wxCLIP_CHILDREN) | |
76 | wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) | |
77 | wxFLAGS_MEMBER(wxWANTS_CHARS) | |
cb0afb26 | 78 | wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) |
3ff066a4 SC |
79 | wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) |
80 | wxFLAGS_MEMBER(wxVSCROLL) | |
81 | wxFLAGS_MEMBER(wxHSCROLL) | |
bc9fb572 | 82 | |
3ff066a4 | 83 | wxEND_FLAGS( wxStaticBoxStyle ) |
bc9fb572 | 84 | |
51741307 SC |
85 | IMPLEMENT_DYNAMIC_CLASS_XTI(wxStaticBox, wxControl,"wx/statbox.h") |
86 | ||
3ff066a4 | 87 | wxBEGIN_PROPERTIES_TABLE(wxStaticBox) |
57f4f925 | 88 | wxPROPERTY( Label,wxString, SetLabel, GetLabel, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) |
af498247 | 89 | wxPROPERTY_FLAGS( WindowStyle , wxStaticBoxStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style |
066f1b7a | 90 | /* |
57f4f925 WS |
91 | TODO PROPERTIES : |
92 | label | |
066f1b7a | 93 | */ |
3ff066a4 | 94 | wxEND_PROPERTIES_TABLE() |
51741307 | 95 | |
3ff066a4 SC |
96 | wxBEGIN_HANDLERS_TABLE(wxStaticBox) |
97 | wxEND_HANDLERS_TABLE() | |
51741307 | 98 | |
57f4f925 | 99 | wxCONSTRUCTOR_6( wxStaticBox , wxWindow* , Parent , wxWindowID , Id , wxString , Label , wxPoint , Position , wxSize , Size , long , WindowStyle ) |
51741307 SC |
100 | #else |
101 | IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl) | |
102 | #endif | |
2bda0e17 | 103 | |
3f2711d5 VZ |
104 | // ============================================================================ |
105 | // implementation | |
106 | // ============================================================================ | |
107 | ||
108 | // ---------------------------------------------------------------------------- | |
109 | // wxStaticBox | |
110 | // ---------------------------------------------------------------------------- | |
111 | ||
112 | bool wxStaticBox::Create(wxWindow *parent, | |
113 | wxWindowID id, | |
114 | const wxString& label, | |
115 | const wxPoint& pos, | |
116 | const wxSize& size, | |
117 | long style, | |
118 | const wxString& name) | |
2bda0e17 | 119 | { |
11b6a93b | 120 | if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) ) |
57f4f925 | 121 | return false; |
2bda0e17 | 122 | |
301e257b VZ |
123 | if ( !MSWCreateControl(wxT("BUTTON"), BS_GROUPBOX, pos, size, label, |
124 | WS_EX_TRANSPARENT) ) | |
57f4f925 | 125 | return false; |
2bda0e17 | 126 | |
57f4f925 | 127 | return true; |
2bda0e17 KB |
128 | } |
129 | ||
f68586e5 | 130 | wxSize wxStaticBox::DoGetBestSize() const |
2bda0e17 | 131 | { |
4438caf4 | 132 | int cx, cy; |
7a5e53ab | 133 | wxGetCharSize(GetHWND(), &cx, &cy, GetFont()); |
2bda0e17 | 134 | |
4438caf4 VZ |
135 | int wBox; |
136 | GetTextExtent(wxGetWindowText(m_hWnd), &wBox, &cy); | |
2bda0e17 | 137 | |
4438caf4 VZ |
138 | wBox += 3*cx; |
139 | int hBox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy); | |
2bda0e17 | 140 | |
4438caf4 VZ |
141 | return wxSize(wBox, hBox); |
142 | } | |
2bda0e17 | 143 | |
b04093c9 VZ |
144 | WXHBRUSH |
145 | wxStaticBox::MSWGetBgBrushForSelf(wxWindow *parent, WXHDC WXUNUSED(pDC)) | |
146 | { | |
147 | // we can't use pattern brushes because, apparently, the window proc of our | |
148 | // class does something which invalidates the brush origin before drawing | |
149 | // with it and so any patetrn brush is used incorrectly as can be seen by | |
150 | // putting a static box inside a (themed) notebook | |
151 | // | |
152 | // so always use solid brush for painting the background (note that this | |
153 | // only applies to the background of the box label, not the insides of the | |
154 | // box itself) | |
155 | return parent->MSWGetSolidBgBrushForChild(this); | |
156 | } | |
157 | ||
1e6feb95 | 158 | #endif // wxUSE_STATBOX |