| 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 | bool wxStaticBox::Create( wxWindow* pParent, |
| 26 | wxWindowID vId, |
| 27 | const wxString& rsLabel, |
| 28 | const wxPoint& rPos, |
| 29 | const wxSize& rSize, |
| 30 | long lStyle, |
| 31 | const wxString& rsName ) |
| 32 | { |
| 33 | if(!CreateControl( pParent |
| 34 | ,vId |
| 35 | ,rPos |
| 36 | ,rSize |
| 37 | ,lStyle |
| 38 | ,wxDefaultValidator |
| 39 | ,rsName |
| 40 | )) |
| 41 | { |
| 42 | return false; |
| 43 | } |
| 44 | |
| 45 | wxPoint vPos(0,0); |
| 46 | wxSize vSize(0,0); |
| 47 | |
| 48 | if (!OS2CreateControl( wxT("STATIC") |
| 49 | ,SS_GROUPBOX |
| 50 | ,vPos |
| 51 | ,vSize |
| 52 | ,rsLabel |
| 53 | )) |
| 54 | { |
| 55 | return false; |
| 56 | } |
| 57 | |
| 58 | // |
| 59 | // To be transparent we should have the same colour as the parent as well |
| 60 | // |
| 61 | SetBackgroundColour(GetParent()->GetBackgroundColour()); |
| 62 | |
| 63 | LONG lColor = (LONG)wxBLACK->GetPixel(); |
| 64 | ::WinSetPresParam( m_hWnd |
| 65 | ,PP_FOREGROUNDCOLOR |
| 66 | ,sizeof(LONG) |
| 67 | ,(PVOID)&lColor |
| 68 | ); |
| 69 | |
| 70 | lColor = (LONG)m_backgroundColour.GetPixel(); |
| 71 | ::WinSetPresParam( m_hWnd |
| 72 | ,PP_BACKGROUNDCOLOR |
| 73 | ,sizeof(LONG) |
| 74 | ,(PVOID)&lColor |
| 75 | ); |
| 76 | SetSize( rPos.x |
| 77 | ,rPos.y |
| 78 | ,rSize.x |
| 79 | ,rSize.y |
| 80 | ); |
| 81 | return true; |
| 82 | } // end of wxStaticBox::Create |
| 83 | |
| 84 | wxSize wxStaticBox::DoGetBestSize() const |
| 85 | { |
| 86 | int nCx; |
| 87 | int nCy; |
| 88 | int wBox; |
| 89 | |
| 90 | nCx = GetCharWidth(); |
| 91 | nCy = GetCharHeight(); |
| 92 | GetTextExtent( wxGetWindowText(m_hWnd) |
| 93 | ,&wBox |
| 94 | ,NULL |
| 95 | ); |
| 96 | wBox += 3 * nCx; |
| 97 | |
| 98 | int hBox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(nCy); |
| 99 | |
| 100 | return wxSize( wBox |
| 101 | ,hBox |
| 102 | ); |
| 103 | } // end of wxStaticBox::DoGetBestSize |
| 104 | |
| 105 | MRESULT wxStaticBox::OS2WindowProc( WXUINT nMsg, |
| 106 | WXWPARAM wParam, |
| 107 | WXLPARAM lParam ) |
| 108 | { |
| 109 | return wxControl::OS2WindowProc(nMsg, wParam, lParam); |
| 110 | } // end of wxStaticBox::OS2WindowProc |