]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/statbox.cpp
Avoid clash with control container event handlers
[wxWidgets.git] / src / os2 / statbox.cpp
index b239dc738c830175d1f18afc795245ca00b4ecee..8ae9f4d7ab86a0f47a8d5dbadc3a5b64b8aa787c 100644 (file)
 /////////////////////////////////////////////////////////////////////////////
-// Name:        statbox.cpp
+// Name:        src/os2/statbox.cpp
 // Purpose:     wxStaticBox
-// Author:      AUTHOR
+// Author:      David Webster
 // Modified by:
 // Created:     ??/??/98
 // RCS-ID:      $Id$
-// Copyright:   (c) AUTHOR
-// Licence:    wxWindows licence
+// Copyright:   (c) David Webster
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
-#pragma implementation "statbox.h"
-#endif
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
 
 #include "wx/statbox.h"
 
-#if !USE_SHARED_LIBRARY
-IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
+#ifndef WX_PRECOMP
+    #include "wx/app.h"
+    #include "wx/dcclient.h"
+    #include "wx/window.h"
+#endif
 
-BEGIN_EVENT_TABLE(wxStaticBox, wxControl)
-       EVT_ERASE_BACKGROUND(wxStaticBox::OnEraseBackground)
-END_EVENT_TABLE()
+#include "wx/os2/private.h"
 
-#endif
+IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
 
-/*
- * Static box
- */
-bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
-           const wxString& label,
-           const wxPoint& pos,
-           const wxSize& size,
-           long style,
-           const wxString& name)
+bool wxStaticBox::Create( wxWindow*       pParent,
+                          wxWindowID      vId,
+                          const wxString& rsLabel,
+                          const wxPoint&  rPos,
+                          const wxSize&   rSize,
+                          long            lStyle,
+                          const wxString& rsName )
 {
-    SetName(name);
+    if(!CreateControl( pParent
+                      ,vId
+                      ,rPos
+                      ,rSize
+                      ,lStyle
+                      ,wxDefaultValidator
+                      ,rsName
+                     ))
+    {
+        return false;
+    }
 
-    if (parent) parent->AddChild(this);
+    wxPoint  vPos(0,0);
+    wxSize   vSize(0,0);
 
-    if ( id == -1 )
-           m_windowId = (int)NewControlId();
-    else
-           m_windowId = id;
+    if (!OS2CreateControl( wxT("STATIC")
+                          ,SS_GROUPBOX
+                          ,vPos
+                          ,vSize
+                          ,rsLabel
+                         ))
+    {
+        return false;
+    }
 
-    m_windowStyle = style;
+    //
+    // To be transparent we should have the same colour as the parent as well
+    //
+    SetBackgroundColour(GetParent()->GetBackgroundColour());
 
-    // TODO: create static box
-    return FALSE;
-}
+    LONG lColor = (LONG)wxBLACK->GetPixel();
+    ::WinSetPresParam( m_hWnd
+                      ,PP_FOREGROUNDCOLOR
+                      ,sizeof(LONG)
+                      ,(PVOID)&lColor
+                     );
 
-void wxStaticBox::SetLabel(const wxString& label)
-{
-    // TODO
-}
+    lColor = (LONG)m_backgroundColour.GetPixel();
+    ::WinSetPresParam( m_hWnd
+                      ,PP_BACKGROUNDCOLOR
+                      ,sizeof(LONG)
+                      ,(PVOID)&lColor
+                     );
+    SetSize( rPos.x
+            ,rPos.y
+            ,rSize.x
+            ,rSize.y
+           );
+    return true;
+} // end of wxStaticBox::Create
 
-void wxStaticBox::SetSize(int x, int y, int width, int height, int sizeFlags)
+wxSize wxStaticBox::DoGetBestSize() const
 {
-    // TODO
-}
+    int                             nCx;
+    int                             nCy;
+    int                             wBox;
+
+    nCx = GetCharWidth();
+    nCy = GetCharHeight();
+    GetTextExtent( wxGetWindowText(m_hWnd)
+                  ,&wBox
+                  ,NULL
+                 );
+    wBox += 3 * nCx;
+
+    int                             hBox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(nCy);
 
+    return wxSize( wBox
+                  ,hBox
+                 );
+} // end of wxStaticBox::DoGetBestSize
+
+MRESULT wxStaticBox::OS2WindowProc( WXUINT    nMsg,
+                                    WXWPARAM  wParam,
+                                    WXLPARAM  lParam )
+{
+    return wxControl::OS2WindowProc(nMsg, wParam, lParam);
+} // end of wxStaticBox::OS2WindowProc