From 1b086de1460fd46c21a432ac3d8dec2759e5d05a Mon Sep 17 00:00:00 2001 From: David Webster Date: Fri, 18 Jan 2002 17:01:08 +0000 Subject: [PATCH] Various OS/2 changes to keep up with general library changes and some new dilaog support. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13639 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/os2/control.cpp | 2 + src/os2/makefile.va | 9 ++- src/os2/mdi.cpp | 8 +++ src/os2/radiobut.cpp | 159 +++++++++++++++++++++---------------------- src/os2/toplevel.cpp | 10 +-- src/os2/window.cpp | 41 ++--------- 6 files changed, 104 insertions(+), 125 deletions(-) diff --git a/src/os2/control.cpp b/src/os2/control.cpp index f1168950f8..086830056c 100644 --- a/src/os2/control.cpp +++ b/src/os2/control.cpp @@ -135,6 +135,8 @@ bool wxControl::OS2CreateControl( zClass = WC_COMBOBOX; else if ((strcmp(zClassname, "STATIC")) == 0) zClass = WC_STATIC; + else if ((strcmp(zClassname, "BUTTON")) == 0) + zClass = WC_BUTTON; dwStyle |= WS_VISIBLE; // diff --git a/src/os2/makefile.va b/src/os2/makefile.va index ca3af59645..207bed6be3 100644 --- a/src/os2/makefile.va +++ b/src/os2/makefile.va @@ -251,6 +251,7 @@ COMMONOBJS = \ ..\common\$D\imagbmp.obj \ ..\common\$D\image.obj \ ..\common\$D\imaggif.obj \ + ..\common\$D\imagiff.obj \ ..\common\$D\imagjpeg.obj \ ..\common\$D\imagpcx.obj \ ..\common\$D\imagpng.obj \ @@ -381,6 +382,7 @@ COMLIBOBJS2 = \ imagbmp.obj \ image.obj \ imaggif.obj \ + imagiff.obj \ imagjpeg.obj \ imagpcx.obj \ imagpng.obj \ @@ -407,10 +409,10 @@ COMLIBOBJS2 = \ popupcmn.obj \ prntbase.obj \ process.obj \ - protocol.obj \ - quantize.obj + protocol.obj COMLIBOBJS3 = \ + quantize.obj \ radiocmn.obj \ regex.obj \ resource.obj \ @@ -747,6 +749,7 @@ $(COMLIBOBJS2): copy ..\common\$D\imagbmp.obj copy ..\common\$D\image.obj copy ..\common\$D\imaggif.obj + copy ..\common\$D\imagiff.obj copy ..\common\$D\imagjpeg.obj copy ..\common\$D\imagpcx.obj copy ..\common\$D\imagpng.obj @@ -774,9 +777,9 @@ $(COMLIBOBJS2): copy ..\common\$D\prntbase.obj copy ..\common\$D\process.obj copy ..\common\$D\protocol.obj - copy ..\common\$D\quantize.obj $(COMLIBOBJS3): + copy ..\common\$D\quantize.obj copy ..\common\$D\radiocmn.obj copy ..\common\$D\regex.obj copy ..\common\$D\resource.obj diff --git a/src/os2/mdi.cpp b/src/os2/mdi.cpp index 59a2fc778d..1fccebacb2 100644 --- a/src/os2/mdi.cpp +++ b/src/os2/mdi.cpp @@ -80,9 +80,17 @@ inline bool IsMdiCommandId(int id) return (id >= wxFIRST_MDI_CHILD) && (id <= wxLAST_MDI_CHILD); } +// unpack the parameters of WM_MDIACTIVATE message static void UnpackMDIActivate(WXWPARAM wParam, WXLPARAM lParam, WXWORD *activate, WXHWND *hwndAct, WXHWND *hwndDeact); +// return the HMENU of the MDI menu +static inline HMENU GetMDIWindowMenu(wxMDIParentFrame *frame) +{ + wxMenu *menu = frame->GetWindowMenu(); + return menu ? GetHmenuOf(menu) : 0; +} + // =========================================================================== // implementation // =========================================================================== diff --git a/src/os2/radiobut.cpp b/src/os2/radiobut.cpp index 83444cd1f0..f06181dd45 100644 --- a/src/os2/radiobut.cpp +++ b/src/os2/radiobut.cpp @@ -27,6 +27,11 @@ IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl) +void wxRadioButton::Init() +{ + m_bFocusJustSet = FALSE; +} // end of wxRadioButton::Init + void wxRadioButton::Command ( wxCommandEvent& rEvent ) @@ -48,102 +53,80 @@ bool wxRadioButton::Create( , const wxString& rsName ) { - int nX = rPos.x; - int nY = rPos.y; - int nWidth = rSize.x; - int nHeight = rSize.y; - long lsStyle = 0L; - long lGroupStyle = 0L; - - SetName(rsName); + if ( !CreateControl( pParent + ,vId + ,rPos + ,rSize + ,lStyle #if wxUSE_VALIDATORS - SetValidator(rValidator); + ,rValidator #endif + ,rsName)) + return FALSE; - if (pParent) - pParent->AddChild(this); + long lSstyle = HasFlag(wxRB_GROUP) ? WS_GROUP : 0; - SetBackgroundColour(pParent->GetBackgroundColour()); - SetForegroundColour(pParent->GetForegroundColour()); + lSstyle |= BS_AUTORADIOBUTTON; - if (vId == -1) - m_windowId = (int)NewControlId(); - else - m_windowId = vId; + if (HasFlag(wxCLIP_SIBLINGS)) + lSstyle |= WS_CLIPSIBLINGS; + + if (!OS2CreateControl( _T("BUTTON") + ,lSstyle + ,rPos + ,rSize + ,rsLabel + ,0 + )) + return FALSE; + if (HasFlag(wxRB_GROUP)) + SetValue(TRUE); - m_windowStyle = lStyle ; + SetFont(*wxSMALL_FONT); + SetSize( rPos.x + ,rPos.y + ,rSize.x + ,rSize.y + ); + return TRUE; +} // end of wxRadioButton::Create - if (m_windowStyle & wxRB_GROUP) - lGroupStyle = WS_GROUP; +wxSize wxRadioButton::DoGetBestSize() const +{ + static int snRadioSize = 0; - lsStyle = lGroupStyle | BS_AUTORADIOBUTTON | WS_VISIBLE ; + if (!snRadioSize) + { + wxScreenDC vDC; - if (m_windowStyle & wxCLIP_SIBLINGS ) - lsStyle |= WS_CLIPSIBLINGS; - // - // If the parent is a scrolled window the controls must - // have this style or they will overlap the scrollbars - // - if (pParent) - if (pParent->IsKindOf(CLASSINFO(wxScrolledWindow)) || - pParent->IsKindOf(CLASSINFO(wxGenericScrolledWindow))) - lsStyle |= WS_CLIPSIBLINGS; - - m_hWnd = (WXHWND)::WinCreateWindow ( GetHwndOf(pParent) - ,WC_BUTTON - ,rsLabel.c_str() - ,lsStyle - ,0, 0, 0, 0 - ,GetWinHwnd(pParent) - ,HWND_TOP - ,(HMENU)m_windowId - ,NULL - ,NULL - ); - wxCHECK_MSG(m_hWnd, FALSE, wxT("Failed to create radiobutton")); - - if (rsLabel != wxT("")) + vDC.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); + snRadioSize = vDC.GetCharHeight(); + } + + wxString sStr = GetLabel(); + int nRadioWidth; + int nRadioHeight; + + if (!sStr.empty()) { - int nLabelWidth; - int nLabelHeight; - - GetTextExtent( rsLabel - ,&nLabelWidth - ,&nLabelHeight - ,NULL - ,NULL - ,&this->GetFont() + GetTextExtent( sStr + ,&nRadioWidth + ,&nRadioHeight ); - if (nWidth < 0) - nWidth = (int)(nLabelWidth + RADIO_SIZE); - if (nHeight<0) - { - nHeight = (int)(nLabelHeight); - if (nHeight < RADIO_SIZE) - nHeight = RADIO_SIZE; - } + nRadioWidth += snRadioSize + GetCharWidth(); + if (nRadioHeight < snRadioSize) + nRadioHeight = snRadioSize; } else { - if (nWidth < 0) - nWidth = RADIO_SIZE; - if (nHeight < 0) - nHeight = RADIO_SIZE; + nRadioWidth = snRadioSize; + nRadioHeight = snRadioSize; } - - // - // Subclass again for purposes of dialog editing mode - // - SubclassWin((WXHWND)m_hWnd); - SetFont(pParent->GetFont()); - SetSize( nX - ,nY - ,nWidth - ,nHeight - ); - return FALSE; -} // end of wxRadioButton::Create + return wxSize( nRadioWidth + ,nRadioHeight + ); +} // end of wxRadioButton::DoGetBestSize // // Get single selection, for single choice list items @@ -172,6 +155,22 @@ bool wxRadioButton::OS2Command( return FALSE; } // end of wxRadioButton::OS2Command +void wxRadioButton::SetFocus() +{ + // when the radio button receives a WM_SETFOCUS message it generates a + // BN_CLICKED which is totally unexpected and leads to catastrophic results + // if you pop up a dialog from the radio button event handler as, when the + // dialog is dismissed, the focus is returned to the radio button which + // generates BN_CLICKED which leads to showing another dialog and so on + // without end! + // + // to aviod this, we drop the pseudo BN_CLICKED events generated when the + // button gains focus + m_bFocusJustSet = TRUE; + + wxControl::SetFocus(); +} + void wxRadioButton::SetLabel( const wxString& rsLabel ) diff --git a/src/os2/toplevel.cpp b/src/os2/toplevel.cpp index b135598646..7596ef7dcc 100644 --- a/src/os2/toplevel.cpp +++ b/src/os2/toplevel.cpp @@ -197,15 +197,15 @@ bool wxTopLevelWindowOS2::CreateDialog( } HWND hWndDlg; - HWND hWndParent; + HWND hWndOwner; if (pParent) - hWndParent = GetHwndOf(pParent); + hWndOwner = GetHwndOf(pParent); else - hWndParent = HWND_DESKTOP; + hWndOwner = HWND_DESKTOP; - hWndDlg = ::WinLoadDlg( hWndParent - ,hWndParent + hWndDlg = ::WinLoadDlg( HWND_DESKTOP + ,hWndOwner ,(PFNWP)wxDlgProc ,NULL ,(ULONG)ulDlgTemplate diff --git a/src/os2/window.cpp b/src/os2/window.cpp index eecbf1479c..f0f385d7b0 100644 --- a/src/os2/window.cpp +++ b/src/os2/window.cpp @@ -327,7 +327,6 @@ wxWindowOS2::~wxWindowOS2() { m_isBeingDeleted = TRUE; - OS2DetachWindowMenu(); for (wxWindow* pWin = GetParent(); pWin; pWin = pWin->GetParent()) { wxFrame* pFrame = wxDynamicCast(pWin, wxFrame); @@ -1545,7 +1544,7 @@ void wxWindowOS2::DoMoveWindow( HWND hParent; wxWindow* pParent = GetParent(); - if (pParent) + if (pParent && !IsKindOf(CLASSINFO(wxDialog))) { int nOS2Height = GetOS2ParentHeight(pParent); @@ -1607,7 +1606,7 @@ void wxWindowOS2::DoSetSize( int nY2 = nY; wxWindow* pParent = (wxWindow*)GetParent(); - if (pParent) + if (pParent && !IsKindOf(CLASSINFO(wxDialog))) { int nOS2Height = GetOS2ParentHeight(pParent); @@ -2718,6 +2717,8 @@ MRESULT wxWindowOS2::OS2WindowProc( #endif // __WXDEBUG__ if (IsKindOf(CLASSINFO(wxFrame))) mResult = ::WinDefWindowProc(m_hWnd, uMsg, wParam, lParam); + else if (IsKindOf(CLASSINFO(wxDialog))) + mResult = ::WinDefDlgProc( m_hWnd, uMsg, wParam, lParam); else mResult = OS2DefWindowProc(uMsg, wParam, lParam); } @@ -2808,40 +2809,6 @@ void wxWindowOS2::OS2DestroyWindow() { } -void wxWindowOS2::OS2DetachWindowMenu() -{ -#ifndef __WXUNIVERSAL__ - if (m_hMenu) - { - HMENU hMenu = (HMENU)m_hMenu; - - int nN = (int)::WinSendMsg(hMenu, MM_QUERYITEMCOUNT, 0, 0); - int i; - - for (i = 0; i < nN; i++) - { - wxChar zBuf[100]; - int nChars = (int)::WinSendMsg( hMenu - ,MM_QUERYITEMTEXT - ,MPFROM2SHORT(i, nN) - ,zBuf - ); - if (!nChars) - { - wxLogLastError(wxT("GetMenuString")); - continue; - } - - if (wxStrcmp(zBuf, wxT("&Window")) == 0) - { - ::WinSendMsg(hMenu, MM_DELETEITEM, MPFROM2SHORT(i, TRUE), 0); - break; - } - } - } -#endif // __WXUNIVERSAL__ -} // end of wxWindowOS2::OS2DetachWindowMenu - bool wxWindowOS2::OS2GetCreateWindowCoords( const wxPoint& rPos , const wxSize& rSize -- 2.45.2