]> git.saurik.com Git - wxWidgets.git/blob - src/os2/statbox.cpp
Wrappers for *ToText
[wxWidgets.git] / src / os2 / statbox.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: 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/window.h"
16 #include "wx/os2/private.h"
17
18 #ifndef WX_PRECOMP
19 #include "wx/app.h"
20 #include "wx/dcclient.h"
21 #endif
22
23 #include "wx/statbox.h"
24
25 IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
26
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 )
36 {
37 if(!CreateControl( pParent
38 ,vId
39 ,rPos
40 ,rSize
41 ,lStyle
42 ,wxDefaultValidator
43 ,rsName
44 ))
45 {
46 return FALSE;
47 }
48
49 wxPoint vPos(0,0);
50 wxSize vSize(0,0);
51
52 if (!OS2CreateControl( "STATIC"
53 ,SS_GROUPBOX
54 ,vPos
55 ,vSize
56 ,rsLabel
57 ))
58 {
59 return FALSE;
60 }
61
62 //
63 // To be transparent we should have the same colour as the parent as well
64 //
65 SetBackgroundColour(GetParent()->GetBackgroundColour());
66
67 wxColour vColour;
68
69 vColour.Set(wxString("BLACK"));
70
71 LONG lColor = (LONG)vColour.GetPixel();
72
73 ::WinSetPresParam( m_hWnd
74 ,PP_FOREGROUNDCOLOR
75 ,sizeof(LONG)
76 ,(PVOID)&lColor
77 );
78 lColor = (LONG)m_backgroundColour.GetPixel();
79
80 ::WinSetPresParam( m_hWnd
81 ,PP_BACKGROUNDCOLOR
82 ,sizeof(LONG)
83 ,(PVOID)&lColor
84 );
85 SetFont(*wxSMALL_FONT);
86 SetSize( rPos.x
87 ,rPos.y
88 ,rSize.x
89 ,rSize.y
90 );
91 return TRUE;
92 } // end of wxStaticBox::Create
93
94 wxSize wxStaticBox::DoGetBestSize() const
95 {
96 int nCx;
97 int nCy;
98 int wBox;
99
100 wxGetCharSize( GetHWND()
101 ,&nCx
102 ,&nCy
103 ,(wxFont*)&GetFont()
104 );
105 GetTextExtent( wxGetWindowText(m_hWnd)
106 ,&wBox
107 ,&nCy
108 );
109 wBox += 3 * nCx;
110
111 int hBox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(nCy);
112
113 return wxSize( wBox
114 ,hBox
115 );
116 } // end of wxStaticBox::DoGetBestSize
117
118 MRESULT wxStaticBox::OS2WindowProc(
119 WXUINT nMsg
120 , WXWPARAM wParam
121 , WXLPARAM lParam
122 )
123 {
124 return wxControl::OS2WindowProc(nMsg, wParam, lParam);
125 } // end of wxStaticBox::OS2WindowProc
126
127