]> git.saurik.com Git - wxWidgets.git/commitdiff
Various OS/2 changes to keep up with general library changes and some new dilaog...
authorDavid Webster <Dave.Webster@bhmi.com>
Fri, 18 Jan 2002 17:01:08 +0000 (17:01 +0000)
committerDavid Webster <Dave.Webster@bhmi.com>
Fri, 18 Jan 2002 17:01:08 +0000 (17:01 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13639 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/os2/control.cpp
src/os2/makefile.va
src/os2/mdi.cpp
src/os2/radiobut.cpp
src/os2/toplevel.cpp
src/os2/window.cpp

index f1168950f8034770a51f78a3d9c907d85d0faa5c..086830056c05947ceb0d58e870c56336e85bc322 100644 (file)
@@ -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;
 
     //
index ca3af59645bf084d11b5e6d9c1eb37c1c94c68f1..207bed6be36657018945594a640d454312213c52 100644 (file)
@@ -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
index 59a2fc778da24d790285670d397ab2c8c108b597..1fccebacb2b32ee3b88f82158db372053a6ed091 100644 (file)
@@ -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
 // ===========================================================================
index 83444cd1f0fa7f0f6cc09accff9eb0bb63269e32..f06181dd45bea2884a5301a65ab3f6ee76e3febc 100644 (file)
 
 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
 )
index b135598646582694ac66c5fe2e53b4f33fa997cf..7596ef7dccac1f32e42f4b80ee4b7d44ab660eaa 100644 (file)
@@ -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
index eecbf1479cba51ca289e201326068c0ed0777c87..f0f385d7b0b3f42e794070e0ac31933b845285fd 100644 (file)
@@ -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