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