]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/control.cpp
   1 ///////////////////////////////////////////////////////////////////////////// 
   3 // Purpose:     wxControl class 
   4 // Author:      David Webster 
   8 // Copyright:   (c) Julian Smart and Markus Holzem 
   9 // Licence:     wxWindows licence 
  10 ///////////////////////////////////////////////////////////////////////////// 
  13 #pragma implementation "control.h" 
  16 // For compilers that support precompilation, includes "wx.h". 
  17 #include "wx/wxprec.h" 
  22 #include "wx/dcclient.h" 
  24 #include "wx/os2/private.h" 
  25 #include "wx/control.h" 
  27 IMPLEMENT_ABSTRACT_CLASS(wxControl
, wxWindow
) 
  29 BEGIN_EVENT_TABLE(wxControl
, wxWindow
) 
  30     EVT_ERASE_BACKGROUND(wxControl::OnEraseBackground
) 
  34 wxControl::wxControl() 
  36   m_backgroundColour 
= *wxWHITE
; 
  37   m_foregroundColour 
= *wxBLACK
; 
  39 #if WXWIN_COMPATIBILITY 
  41 #endif // WXWIN_COMPATIBILITY 
  42 } // end of wxControl::wxControl 
  44 bool wxControl::Create( 
  51 , const wxValidator
&                rValidator
 
  53 , const wxString
&                   rsName
 
  56     bool                            bRval 
= wxWindow::Create( pParent
 
  66         SetValidator(rValidator
); 
  70 } // end of wxControl::Create 
  72 wxControl::~wxControl() 
  74     m_isBeingDeleted 
= TRUE
; 
  77 bool wxControl::OS2CreateControl( 
  78   const wxChar
*                     zClassname
 
  82 , const wxString
&                   rsLabel
 
  87     // Doesn't do anything at all under OS/2 
  89     if (dwExstyle 
== (WXDWORD
)-1) 
  91         dwExstyle 
= GetExStyle(dwStyle
); 
  97         wxLogError(wxT("Failed to create a control of class '%s'"), zClassname
); 
 102     dwStyle 
|= WS_VISIBLE
; 
 103     m_hWnd 
= (WXHWND
)::WinCreateWindow( (HWND
)GetHwndOf(GetParent()) // Parent window handle 
 104                                        ,(PSZ
)zClassname              
// Window class 
 105                                        ,(PSZ
)rsLabel
.c_str()         // Initial Text 
 106                                        ,(ULONG
)dwStyle               
// Style flags 
 107                                        ,(LONG
)rPos
.x                 
// X pos of origin 
 108                                        ,(LONG
)rPos
.y                 
// Y pos of origin 
 109                                        ,(LONG
)rSize
.x                
// control width 
 110                                        ,(LONG
)rSize
.y                
// control height 
 111                                        ,(HWND
)GetHwndOf(GetParent()) // owner window handle (same as parent 
 112                                        ,HWND_TOP                     
// initial z position 
 113                                        ,(ULONG
)GetId()               // Window identifier 
 114                                        ,NULL                         
// no control data 
 115                                        ,NULL                         
// no Presentation parameters 
 119     // Subclass again for purposes of dialog editing mode 
 124     // Controls use the same font and colours as their parent dialog by default 
 128 } // end of wxControl::OS2CreateControl 
 130 wxSize 
wxControl::DoGetBestSize() const 
 132     return wxSize(DEFAULT_ITEM_WIDTH
, DEFAULT_ITEM_HEIGHT
); 
 133 } // end of wxControl::DoGetBestSize 
 135 bool wxControl::ProcessCommand(wxCommandEvent
& event
) 
 137 #if WXWIN_COMPATIBILITY 
 140         (void)(*m_callback
)(this, event
); 
 145 #endif // WXWIN_COMPATIBILITY 
 147     return GetEventHandler()->ProcessEvent(event
); 
 150 WXHBRUSH 
wxControl::OnCtlColor( 
 159     HPS                             hPS 
= (HPS
)hWxDC
; // pass in a PS handle in OS/2 
 160     wxColour                        vColFore 
= GetForegroundColour(); 
 161     wxColour                        vColBack 
= GetBackgroundColour(); 
 163     if (GetParent()->GetTransparentBackground()) 
 164         ::GpiSetBackMix(hPS
, BM_LEAVEALONE
); 
 166         ::GpiSetBackMix(hPS
, BM_OVERPAINT
); 
 168     ::GpiSetBackColor(hPS
, vColBack
.GetPixel()); 
 169     ::GpiSetColor(hPS
, vColFore
.GetPixel()); 
 171     wxBrush
*                        pBrush 
= wxTheBrushList
->FindOrCreateBrush( vColBack
 
 174     return (WXHBRUSH
)pBrush
->GetResourceHandle(); 
 175 } // end of wxControl::OnCtlColor 
 177 void wxControl::OnEraseBackground( 
 182     HPS                             hPS 
= rEvent
.GetDC()->GetHPS(); 
 185     ::GpiSetPS(hPS
, &vSize
, PU_PELS 
| GPIF_DEFAULT
); 
 186     ::WinQueryWindowRect((HWND
)GetHwnd(), &vRect
); 
 187     ::WinFillRect(hPS
, &vRect
, GetBackgroundColour().GetPixel()); 
 188 } // end of wxControl::OnEraseBackground 
 190 WXDWORD 
wxControl::GetExStyle( 
 195     // Meaningless under OS/2, just return what was sent 
 197     WXDWORD                         exStyle 
= rStyle
; 
 200 } // end of wxControl::GetExStyle 
 202 // --------------------------------------------------------------------------- 
 204 // --------------------------------------------------------------------------- 
 206 // Call this repeatedly for several wnds to find the overall size 
 208 // Call it initially with -1 for all values in rect. 
 209 // Keep calling for other widgets, and rect will be modified 
 210 // to calculate largest bounding rectangle. 
 216     int                             nLeft 
= pRect
->xLeft
; 
 217     int                             nRight 
= pRect
->xRight
; 
 218     int                             nTop 
= pRect
->yTop
; 
 219     int                             nBottom 
= pRect
->yBottom
; 
 221     ::WinQueryWindowRect((HWND
)hWnd
, pRect
); 
 226     if (nLeft 
< pRect
->xLeft
) 
 227         pRect
->xLeft 
= nLeft
; 
 229     if (nRight 
> pRect
->xRight
) 
 230         pRect
->xRight 
= nRight
; 
 232     if (nTop 
< pRect
->yTop
) 
 235     if (nBottom 
> pRect
->yBottom
) 
 236         pRect
->yBottom 
= nBottom
; 
 237 } // end of wxFindMaxSize