]>
Commit | Line | Data |
---|---|---|
0e320a79 DW |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: statbox.cpp | |
3 | // Purpose: wxStaticBox | |
409c9842 | 4 | // Author: David Webster |
0e320a79 DW |
5 | // Modified by: |
6 | // Created: ??/??/98 | |
7 | // RCS-ID: $Id$ | |
409c9842 DW |
8 | // Copyright: (c) David Webster |
9 | // Licence: wxWindows licence | |
0e320a79 DW |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
409c9842 DW |
12 | // For compilers that support precompilation, includes "wx.h". |
13 | #include "wx/wxprec.h" | |
14 | ||
15 | #include "wx/window.h" | |
16 | #include "wx/os2/private.h" | |
17 | ||
18 | #ifndef WX_PRECOMP | |
19 | #include "wx/app.h" | |
20 | #include "wx/dcclient.h" | |
0e320a79 DW |
21 | #endif |
22 | ||
23 | #include "wx/statbox.h" | |
24 | ||
0e320a79 DW |
25 | IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl) |
26 | ||
3c299c3a DW |
27 | bool wxStaticBox::Create( |
28 | wxWindow* pParent | |
29 | , wxWindowID vId | |
30 | , const wxString& rsLabel | |
31 | , const wxPoint& rPos | |
32 | , const wxSize& rSize | |
33 | , long lStyle | |
34 | , const wxString& rsName | |
35 | ) | |
0e320a79 | 36 | { |
b9b1d6c8 DW |
37 | if(!CreateControl( pParent |
38 | ,vId | |
39 | ,rPos | |
40 | ,rSize | |
41 | ,lStyle | |
3c299c3a | 42 | #if wxUSE_VALIDATORS |
b9b1d6c8 | 43 | ,wxDefaultValidator |
409c9842 | 44 | #endif |
b9b1d6c8 DW |
45 | ,rsName |
46 | )) | |
3c299c3a DW |
47 | { |
48 | return FALSE; | |
49 | } | |
409c9842 | 50 | |
3c299c3a DW |
51 | wxPoint vPos(0,0); |
52 | wxSize vSize(0,0); | |
409c9842 | 53 | |
3c299c3a DW |
54 | if (!OS2CreateControl( "STATIC" |
55 | ,SS_GROUPBOX | |
56 | ,vPos | |
57 | ,vSize | |
58 | ,rsLabel | |
59 | )) | |
60 | { | |
61 | return FALSE; | |
62 | } | |
409c9842 | 63 | |
b9b1d6c8 DW |
64 | // |
65 | // To be transparent we should have the same colour as the parent as well | |
66 | // | |
67 | SetBackgroundColour(GetParent()->GetBackgroundColour()); | |
68 | ||
3c299c3a | 69 | wxColour vColour; |
409c9842 | 70 | |
3c299c3a | 71 | vColour.Set(wxString("BLACK")); |
0e320a79 | 72 | |
3c299c3a | 73 | LONG lColor = (LONG)vColour.GetPixel(); |
0e320a79 | 74 | |
3c299c3a DW |
75 | ::WinSetPresParam( m_hWnd |
76 | ,PP_FOREGROUNDCOLOR | |
77 | ,sizeof(LONG) | |
78 | ,(PVOID)&lColor | |
79 | ); | |
7993e67c DW |
80 | lColor = (LONG)m_backgroundColour.GetPixel(); |
81 | ||
82 | ::WinSetPresParam( m_hWnd | |
83 | ,PP_BACKGROUNDCOLOR | |
84 | ,sizeof(LONG) | |
85 | ,(PVOID)&lColor | |
86 | ); | |
b720b24d | 87 | SetFont(*wxSMALL_FONT); |
3c299c3a DW |
88 | SetSize( rPos.x |
89 | ,rPos.y | |
90 | ,rSize.x | |
91 | ,rSize.y | |
92 | ); | |
93 | return TRUE; | |
94 | } // end of wxStaticBox::Create | |
0e320a79 | 95 | |
3c299c3a | 96 | wxSize wxStaticBox::DoGetBestSize() const |
0e320a79 | 97 | { |
3c299c3a DW |
98 | int nCx; |
99 | int nCy; | |
100 | int wBox; | |
101 | ||
102 | wxGetCharSize( GetHWND() | |
103 | ,&nCx | |
104 | ,&nCy | |
105 | ,(wxFont*)&GetFont() | |
106 | ); | |
107 | GetTextExtent( wxGetWindowText(m_hWnd) | |
108 | ,&wBox | |
109 | ,&nCy | |
110 | ); | |
111 | wBox += 3 * nCx; | |
112 | ||
113 | int hBox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(nCy); | |
114 | ||
115 | return wxSize( wBox | |
116 | ,hBox | |
117 | ); | |
118 | } // end of wxStaticBox::DoGetBestSize | |
119 | ||
120 | MRESULT wxStaticBox::OS2WindowProc( | |
121 | WXUINT nMsg | |
122 | , WXWPARAM wParam | |
123 | , WXLPARAM lParam | |
124 | ) | |
409c9842 | 125 | { |
a885d89a | 126 | return wxControl::OS2WindowProc(nMsg, wParam, lParam); |
3c299c3a | 127 | } // end of wxStaticBox::OS2WindowProc |
0e320a79 | 128 | |
409c9842 | 129 |