]>
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 | 8 | // Copyright: (c) David Webster |
65571936 | 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 | |
b9b1d6c8 | 42 | ,wxDefaultValidator |
b9b1d6c8 DW |
43 | ,rsName |
44 | )) | |
3c299c3a DW |
45 | { |
46 | return FALSE; | |
47 | } | |
409c9842 | 48 | |
3c299c3a DW |
49 | wxPoint vPos(0,0); |
50 | wxSize vSize(0,0); | |
409c9842 | 51 | |
0fba44b4 | 52 | if (!OS2CreateControl( wxT("STATIC") |
3c299c3a DW |
53 | ,SS_GROUPBOX |
54 | ,vPos | |
55 | ,vSize | |
56 | ,rsLabel | |
57 | )) | |
58 | { | |
59 | return FALSE; | |
60 | } | |
409c9842 | 61 | |
b9b1d6c8 DW |
62 | // |
63 | // To be transparent we should have the same colour as the parent as well | |
64 | // | |
65 | SetBackgroundColour(GetParent()->GetBackgroundColour()); | |
66 | ||
3c299c3a | 67 | wxColour vColour; |
409c9842 | 68 | |
0fba44b4 | 69 | vColour.Set(wxString(wxT("BLACK"))); |
0e320a79 | 70 | |
3c299c3a | 71 | LONG lColor = (LONG)vColour.GetPixel(); |
0e320a79 | 72 | |
3c299c3a DW |
73 | ::WinSetPresParam( m_hWnd |
74 | ,PP_FOREGROUNDCOLOR | |
75 | ,sizeof(LONG) | |
76 | ,(PVOID)&lColor | |
77 | ); | |
7993e67c DW |
78 | lColor = (LONG)m_backgroundColour.GetPixel(); |
79 | ||
80 | ::WinSetPresParam( m_hWnd | |
81 | ,PP_BACKGROUNDCOLOR | |
82 | ,sizeof(LONG) | |
83 | ,(PVOID)&lColor | |
84 | ); | |
b720b24d | 85 | SetFont(*wxSMALL_FONT); |
3c299c3a DW |
86 | SetSize( rPos.x |
87 | ,rPos.y | |
88 | ,rSize.x | |
89 | ,rSize.y | |
90 | ); | |
91 | return TRUE; | |
92 | } // end of wxStaticBox::Create | |
0e320a79 | 93 | |
3c299c3a | 94 | wxSize wxStaticBox::DoGetBestSize() const |
0e320a79 | 95 | { |
3c299c3a DW |
96 | int nCx; |
97 | int nCy; | |
98 | int wBox; | |
7804d121 | 99 | wxFont vFont = GetFont(); |
3c299c3a DW |
100 | |
101 | wxGetCharSize( GetHWND() | |
102 | ,&nCx | |
103 | ,&nCy | |
7804d121 | 104 | ,&vFont |
3c299c3a DW |
105 | ); |
106 | GetTextExtent( wxGetWindowText(m_hWnd) | |
107 | ,&wBox | |
108 | ,&nCy | |
109 | ); | |
110 | wBox += 3 * nCx; | |
111 | ||
112 | int hBox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(nCy); | |
113 | ||
114 | return wxSize( wBox | |
115 | ,hBox | |
116 | ); | |
117 | } // end of wxStaticBox::DoGetBestSize | |
118 | ||
119 | MRESULT wxStaticBox::OS2WindowProc( | |
120 | WXUINT nMsg | |
121 | , WXWPARAM wParam | |
122 | , WXLPARAM lParam | |
123 | ) | |
409c9842 | 124 | { |
a885d89a | 125 | return wxControl::OS2WindowProc(nMsg, wParam, lParam); |
3c299c3a | 126 | } // end of wxStaticBox::OS2WindowProc |
0e320a79 | 127 | |
409c9842 | 128 |