]>
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 | { |
3c299c3a DW |
37 | if(!OS2CreateControl( pParent |
38 | ,vId | |
39 | ,rPos | |
40 | ,rSize | |
41 | ,lStyle | |
42 | #if wxUSE_VALIDATORS | |
43 | ,wxDefaultValidator | |
409c9842 | 44 | #endif |
3c299c3a DW |
45 | ,rsName |
46 | )) | |
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 | |
3c299c3a | 64 | wxColour vColour; |
409c9842 | 65 | |
3c299c3a | 66 | vColour.Set(wxString("BLACK")); |
0e320a79 | 67 | |
3c299c3a | 68 | LONG lColor = (LONG)vColour.GetPixel(); |
0e320a79 | 69 | |
3c299c3a DW |
70 | ::WinSetPresParam( m_hWnd |
71 | ,PP_FOREGROUNDCOLOR | |
72 | ,sizeof(LONG) | |
73 | ,(PVOID)&lColor | |
74 | ); | |
7993e67c DW |
75 | lColor = (LONG)m_backgroundColour.GetPixel(); |
76 | ||
77 | ::WinSetPresParam( m_hWnd | |
78 | ,PP_BACKGROUNDCOLOR | |
79 | ,sizeof(LONG) | |
80 | ,(PVOID)&lColor | |
81 | ); | |
b3260bce DW |
82 | wxFont* pTextFont = new wxFont( 10 |
83 | ,wxMODERN | |
84 | ,wxNORMAL | |
85 | ,wxNORMAL | |
86 | ); | |
87 | SetFont(*pTextFont); | |
3c299c3a DW |
88 | SetSize( rPos.x |
89 | ,rPos.y | |
90 | ,rSize.x | |
91 | ,rSize.y | |
92 | ); | |
b3260bce | 93 | delete pTextFont; |
3c299c3a DW |
94 | return TRUE; |
95 | } // end of wxStaticBox::Create | |
0e320a79 | 96 | |
3c299c3a | 97 | wxSize wxStaticBox::DoGetBestSize() const |
0e320a79 | 98 | { |
3c299c3a DW |
99 | int nCx; |
100 | int nCy; | |
101 | int wBox; | |
102 | ||
103 | wxGetCharSize( GetHWND() | |
104 | ,&nCx | |
105 | ,&nCy | |
106 | ,(wxFont*)&GetFont() | |
107 | ); | |
108 | GetTextExtent( wxGetWindowText(m_hWnd) | |
109 | ,&wBox | |
110 | ,&nCy | |
111 | ); | |
112 | wBox += 3 * nCx; | |
113 | ||
114 | int hBox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(nCy); | |
115 | ||
116 | return wxSize( wBox | |
117 | ,hBox | |
118 | ); | |
119 | } // end of wxStaticBox::DoGetBestSize | |
120 | ||
121 | MRESULT wxStaticBox::OS2WindowProc( | |
122 | WXUINT nMsg | |
123 | , WXWPARAM wParam | |
124 | , WXLPARAM lParam | |
125 | ) | |
409c9842 | 126 | { |
a885d89a | 127 | return wxControl::OS2WindowProc(nMsg, wParam, lParam); |
3c299c3a | 128 | } // end of wxStaticBox::OS2WindowProc |
0e320a79 | 129 | |
409c9842 | 130 |