X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5d44b24ee63543390aa28e1eb4ff162da4264838..41efa9a7cb85bec4aefa6aa9324d2d0b45bfc3d3:/src/os2/radiobox.cpp diff --git a/src/os2/radiobox.cpp b/src/os2/radiobox.cpp index 70a9a050e4..b0d640ae17 100644 --- a/src/os2/radiobox.cpp +++ b/src/os2/radiobox.cpp @@ -36,13 +36,22 @@ MRESULT EXPENTRY wxRadioBtnWndProc( HWND hWnd ,MPARAM wParam ,MPARAM lParam ); +MRESULT EXPENTRY wxRadioBoxWndProc( HWND hWnd + ,UINT uMessage + ,MPARAM wParam + ,MPARAM lParam + ); // --------------------------------------------------------------------------- // global vars // --------------------------------------------------------------------------- // the pointer to standard radio button wnd proc +extern void wxAssociateWinWithHandle( HWND hWnd + ,wxWindowOS2* pWin + ); static WXFARPROC fnWndProcRadioBtn = NULL; +static WXFARPROC fnWndProcRadioBox = NULL; // =========================================================================== // implementation @@ -254,24 +263,17 @@ bool wxRadioBox::Create( , const wxString asChoices[] , int nMajorDim , long lStyle -#if wxUSE_VALIDATORS , const wxValidator& rVal -#endif , const wxString& rsName ) { - // - // System fonts are too big in OS/2 and they are blue - // We want smaller fonts and black by default. - // - wxFont& rFont = *wxSMALL_FONT; wxColour vColour; LONG lColor; vColour.Set(wxString("BLACK")); - lColor = (LONG)vColour.GetPixel(); + m_backgroundColour = pParent->GetBackgroundColour(); m_nSelectedButton = -1; - m_nNoItems = nNum; + m_nNoItems = 0; m_nMajorDim = nMajorDim == 0 ? nNum : nMajorDim; m_nNoRowsOrCols = nMajorDim; @@ -279,31 +281,24 @@ bool wxRadioBox::Create( // // Common initialization // - if (!OS2CreateControl( pParent - ,vId - ,rPos - ,rSize - ,lStyle -#if wxUSE_VALIDATORS - ,rVal -#endif - ,rsName - )) - - - - + if (!CreateControl( pParent + ,vId + ,rPos + ,rSize + ,lStyle + ,rVal + ,rsName + )) + return FALSE; if (!OS2CreateControl( "STATIC" -#if RADIOBTN_PARENT_IS_RADIOBOX - ,SS_GROUPBOX | WS_GROUP | WS_CLIPCHILDREN -#else - ,SS_GROUPBOX | WS_GROUP | WS_CLIPSIBLINGS -#endif + ,SS_GROUPBOX ,rPos ,rSize ,rsTitle )) + return FALSE; + wxAssociateWinWithHandle(m_hWnd, this); #if RADIOBTN_PARENT_IS_RADIOBOX HWND hWndParent = GetHwnd(); #else @@ -314,16 +309,12 @@ bool wxRadioBox::Create( // // Some radio boxes test consecutive id. // + m_nNoItems = nNum; (void)NewControlId(); m_ahRadioButtons = new WXHWND[nNum]; m_pnRadioWidth = new int[nNum]; m_pnRadioHeight = new int[nNum]; - if (rFont.Ok()) - { - hFont = rFont.GetResourceHandle(); - } - for (int i = 0; i < nNum; i++) { m_pnRadioWidth[i] = m_pnRadioHeight[i] = -1; @@ -364,8 +355,9 @@ bool wxRadioBox::Create( } m_ahRadioButtons[i] = (WXHWND)hWndBtn; SubclassRadioButton((WXHWND)hWndBtn); + wxAssociateWinWithHandle(hWndBtn, this); wxOS2SetFont( hWndBtn - ,rFont + ,*wxSMALL_FONT ); ::WinSetWindowULong(hWndBtn, QWL_USER, (ULONG)this); m_aSubControls.Add(nNewId); @@ -385,13 +377,22 @@ bool wxRadioBox::Create( ,NULL ,NULL ); - SetFont(*wxSMALL_FONT); + SetFont(*wxSMALL_FONT); + fnWndProcRadioBox = (WXFARPROC)::WinSubclassWindow( GetHwnd() + ,(PFNWP)wxRadioBoxWndProc + ); + ::WinSetWindowULong(GetHwnd(), QWL_USER, (ULONG)this); lColor = (LONG)vColour.GetPixel(); ::WinSetPresParam( m_hWnd ,PP_FOREGROUNDCOLOR ,sizeof(LONG) ,(PVOID)&lColor ); + ::WinSetPresParam( m_hWnd + ,PP_BORDERDARKCOLOR + ,sizeof(LONG) + ,(PVOID)&lColor + ); lColor = (LONG)m_backgroundColour.GetPixel(); ::WinSetPresParam( m_hWnd @@ -399,6 +400,13 @@ bool wxRadioBox::Create( ,sizeof(LONG) ,(PVOID)&lColor ); + ::WinSetPresParam( m_hWnd + ,PP_BORDERLIGHTCOLOR + ,sizeof(LONG) + ,(PVOID)&lColor + ); + SetXComp(0); + SetYComp(0); SetSelection(0); SetSize( rPos.x ,rPos.y @@ -457,7 +465,10 @@ void wxRadioBox::DoSetSize( nXx = nCurrentX; if (nY == -1 && !(nSizeFlags & wxSIZE_ALLOW_MINUS_ONE)) nYy = nCurrentY; - + if (nYy < 0) + nYy = 0; + if (nXx < 0) + nXx = 0; wxGetCharSize( m_hWnd ,&nCx1 @@ -622,6 +633,7 @@ void wxRadioBox::DoSetSize( ,(LONG)nMaxHeight ,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW ); + GetParent()->Refresh(); // // Where do we put the next button? // @@ -958,10 +970,8 @@ bool wxRadioBox::OS2Command( if (nSelectedButton == -1) { // - // Just ignore it - due to a hack with WM_NCHITTEST handling in our - // wnd proc, we can receive dummy click messages when we click near - // the radiobox edge (this is ugly but Julian wouldn't let me get - // rid of this...) + // Just ignore it + // return FALSE; } if (nSelectedButton != m_nSelectedButton) @@ -1202,3 +1212,18 @@ MRESULT wxRadioBtnWndProc( ); } // end of wxRadioBtnWndProc +MRESULT EXPENTRY wxRadioBoxWndProc( + HWND hWnd +, UINT uMessage +, MPARAM wParam +, MPARAM lParam +) +{ + return (fnWndProcRadioBox( hWnd + ,(ULONG)uMessage + ,(MPARAM)wParam + ,(MPARAM)lParam + ) + ); +} // end of wxRadioBoxWndProc +