1///////////////////////////////////////////////////////////////////////////// 2// Name: src/os2/statbox.cpp 3// Purpose: wxStaticBox 4// Author: David Webster 5// Modified by: 6// Created: ??/??/98 7// RCS-ID: $Id: statbox.cpp 39615 2006-06-07 13:26:00Z ABX $ 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 25IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl) 26 27bool 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 LONG lColor = (LONG)wxBLACK->GetPixel(); 66 ::WinSetPresParam( m_hWnd 67 ,PP_FOREGROUNDCOLOR 68 ,sizeof(LONG) 69 ,(PVOID)&lColor 70 ); 71 72 lColor = (LONG)m_backgroundColour.GetPixel(); 73 ::WinSetPresParam( m_hWnd 74 ,PP_BACKGROUNDCOLOR 75 ,sizeof(LONG) 76 ,(PVOID)&lColor 77 ); 78 SetSize( rPos.x 79 ,rPos.y 80 ,rSize.x 81 ,rSize.y 82 ); 83 return true; 84} // end of wxStaticBox::Create 85 86wxSize wxStaticBox::DoGetBestSize() const 87{ 88 int nCx; 89 int nCy; 90 int wBox; 91 92 nCx = GetCharWidth(); 93 nCy = GetCharHeight(); 94 GetTextExtent( wxGetWindowText(m_hWnd) 95 ,&wBox 96 ,NULL 97 ); 98 wBox += 3 * nCx; 99 100 int hBox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(nCy); 101 102 return wxSize( wBox 103 ,hBox 104 ); 105} // end of wxStaticBox::DoGetBestSize 106 107MRESULT wxStaticBox::OS2WindowProc( WXUINT nMsg, 108 WXWPARAM wParam, 109 WXLPARAM lParam ) 110{ 111 return wxControl::OS2WindowProc(nMsg, wParam, lParam); 112} // end of wxStaticBox::OS2WindowProc 113