]> git.saurik.com Git - wxWidgets.git/blob - src/os2/statbox.cpp
survive delete within Notify
[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 #if wxUSE_VALIDATORS
43 ,wxDefaultValidator
44 #endif
45 ,rsName
46 ))
47 {
48 return FALSE;
49 }
50
51 wxPoint vPos(0,0);
52 wxSize vSize(0,0);
53
54 if (!OS2CreateControl( "STATIC"
55 ,SS_GROUPBOX
56 ,vPos
57 ,vSize
58 ,rsLabel
59 ))
60 {
61 return FALSE;
62 }
63
64 //
65 // To be transparent we should have the same colour as the parent as well
66 //
67 SetBackgroundColour(GetParent()->GetBackgroundColour());
68
69 wxColour vColour;
70
71 vColour.Set(wxString("BLACK"));
72
73 LONG lColor = (LONG)vColour.GetPixel();
74
75 ::WinSetPresParam( m_hWnd
76 ,PP_FOREGROUNDCOLOR
77 ,sizeof(LONG)
78 ,(PVOID)&lColor
79 );
80 lColor = (LONG)m_backgroundColour.GetPixel();
81
82 ::WinSetPresParam( m_hWnd
83 ,PP_BACKGROUNDCOLOR
84 ,sizeof(LONG)
85 ,(PVOID)&lColor
86 );
87 wxFont* pTextFont = new wxFont( 10
88 ,wxMODERN
89 ,wxNORMAL
90 ,wxNORMAL
91 );
92 SetFont(*pTextFont);
93 SetSize( rPos.x
94 ,rPos.y
95 ,rSize.x
96 ,rSize.y
97 );
98 delete pTextFont;
99 return TRUE;
100 } // end of wxStaticBox::Create
101
102 wxSize wxStaticBox::DoGetBestSize() const
103 {
104 int nCx;
105 int nCy;
106 int wBox;
107
108 wxGetCharSize( GetHWND()
109 ,&nCx
110 ,&nCy
111 ,(wxFont*)&GetFont()
112 );
113 GetTextExtent( wxGetWindowText(m_hWnd)
114 ,&wBox
115 ,&nCy
116 );
117 wBox += 3 * nCx;
118
119 int hBox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(nCy);
120
121 return wxSize( wBox
122 ,hBox
123 );
124 } // end of wxStaticBox::DoGetBestSize
125
126 MRESULT wxStaticBox::OS2WindowProc(
127 WXUINT nMsg
128 , WXWPARAM wParam
129 , WXLPARAM lParam
130 )
131 {
132 return wxControl::OS2WindowProc(nMsg, wParam, lParam);
133 } // end of wxStaticBox::OS2WindowProc
134
135