]> git.saurik.com Git - wxWidgets.git/commitdiff
OS/2 Updates
authorDavid Webster <Dave.Webster@bhmi.com>
Mon, 20 Mar 2000 00:31:11 +0000 (00:31 +0000)
committerDavid Webster <Dave.Webster@bhmi.com>
Mon, 20 Mar 2000 00:31:11 +0000 (00:31 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6871 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/os2/app.cpp
src/os2/frame.cpp
src/os2/menu.cpp
src/os2/window.cpp

index 961f2f9b16ccf1c2be149a544c202dd99d9b76af..26611eed61698e7b7d90383a40518092070abf19 100644 (file)
@@ -93,12 +93,6 @@ HICON wxDEFAULT_MDIPARENTFRAME_ICON  = (HICON) NULL;
 
 HBRUSH wxDisableButtonBrush = (HBRUSH) 0;
 
-MRESULT EXPENTRY wxWndProc( HWND
-                           ,ULONG
-                           ,MPARAM
-                           ,MPARAM
-                          );
-
 // ===========================================================================
 // implementation
 // ===========================================================================
index f3c22d5db5d40bf5d8bd79aa50fdb6a9240a6fa2..18269f66d1fa8a7817f9a1758de51a3dda7775ea 100644 (file)
@@ -342,37 +342,21 @@ void wxFrame::DoShowWindow(
   int                               bShowCmd
 )
 {
-    HWND                            hClient;
-    HWND                            hTitlebar = NULLHANDLE;
-    HWND                            hHScroll = NULLHANDLE;
-    HWND                            hVScroll = NULLHANDLE;
-    HWND                            hMenuBar = NULLHANDLE;
+    HWND                            hClient = NULLHANDLE;
     SWP                             vSwp;
-    SWP                             vSwpTitlebar;
-    SWP                             vSwpVScroll;
-    SWP                             vSwpHScroll;
-    SWP                             vSwpMenu;
 
     //
-    // Send anything to initialize the frame
+    // Reset the window position
     //
-    WinQueryWindowPos(GetHwnd(), &vSwp);
     hClient = WinWindowFromID(GetHwnd(), FID_CLIENT);
-    hTitlebar = WinWindowFromID(GetHwnd(), FID_TITLEBAR);
-    WinQueryWindowPos(hTitlebar, &vSwpTitlebar);
-    hHScroll = WinWindowFromID(GetHwnd(), FID_HORZSCROLL);
-    WinQueryWindowPos(hHScroll, &vSwpHScroll);
-    hVScroll = WinWindowFromID(GetHwnd(), FID_VERTSCROLL);
-    WinQueryWindowPos(hVScroll, &vSwpVScroll);
-    hMenuBar = WinWindowFromID(GetHwnd(), FID_MENU);
-    WinQueryWindowPos(hMenuBar, &vSwpMenu);
-    WinSetWindowPos( hClient
+    WinQueryWindowPos(GetHwnd(), &vSwp);
+    WinSetWindowPos( GetHwnd()
                     ,HWND_TOP
-                    ,SV_CXSIZEBORDER
-                    ,(SV_CYSIZEBORDER - 1) + vSwpHScroll.cy
-                    ,vSwp.cx - ((SV_CXSIZEBORDER * 2) + vSwpVScroll.cx)
-                    ,vSwp.cy - ((SV_CYSIZEBORDER * 2) + 1 + vSwpTitlebar.cy + vSwpMenu.cy + vSwpHScroll.cy)
-                    ,SWP_SIZE | SWP_MOVE
+                    ,vSwp.x
+                    ,vSwp.y
+                    ,vSwp.cx
+                    ,vSwp.cy
+                    ,SWP_SIZE | SWP_MOVE | SWP_ACTIVATE
                    );
     ::WinShowWindow(GetHwnd(), (BOOL)bShowCmd);
     ::WinShowWindow(hClient, (BOOL)bShowCmd);
@@ -554,6 +538,17 @@ void wxFrame::SetMenuBar(
 {
     ERRORID                         vError;
     wxString                        sError;
+    HWND                            hClient = NULLHANDLE;
+    HWND                            hFrame = NULLHANDLE;
+    HWND                            hTitlebar = NULLHANDLE;
+    HWND                            hHScroll = NULLHANDLE;
+    HWND                            hVScroll = NULLHANDLE;
+    HWND                            hMenuBar = NULLHANDLE;
+    SWP                             vSwp;
+    SWP                             vSwpTitlebar;
+    SWP                             vSwpVScroll;
+    SWP                             vSwpHScroll;
+    SWP                             vSwpMenu;
 
     if (!pMenuBar)
     {
@@ -601,6 +596,28 @@ void wxFrame::SetMenuBar(
 
     m_frameMenuBar = pMenuBar;
     pMenuBar->Attach(this);
+
+    //
+    // Now resize the client to fit the new frame
+    //
+    WinQueryWindowPos(GetHwnd(), &vSwp);
+    hClient = WinWindowFromID(GetHwnd(), FID_CLIENT);
+    hTitlebar = WinWindowFromID(GetHwnd(), FID_TITLEBAR);
+    WinQueryWindowPos(hTitlebar, &vSwpTitlebar);
+    hHScroll = WinWindowFromID(GetHwnd(), FID_HORZSCROLL);
+    WinQueryWindowPos(hHScroll, &vSwpHScroll);
+    hVScroll = WinWindowFromID(GetHwnd(), FID_VERTSCROLL);
+    WinQueryWindowPos(hVScroll, &vSwpVScroll);
+    hMenuBar = WinWindowFromID(GetHwnd(), FID_MENU);
+    WinQueryWindowPos(hMenuBar, &vSwpMenu);
+    WinSetWindowPos( hClient
+                    ,HWND_TOP
+                    ,SV_CXSIZEBORDER/2
+                    ,(SV_CYSIZEBORDER/2) + vSwpHScroll.cy/2
+                    ,vSwp.cx - ((SV_CXSIZEBORDER + 1) + vSwpVScroll.cx)
+                    ,vSwp.cy - ((SV_CYSIZEBORDER + 1) + vSwpTitlebar.cy + vSwpMenu.cy + vSwpHScroll.cy/2)
+                    ,SWP_SIZE | SWP_MOVE
+                   );
 } // end of wxFrame::SetMenuBar
 
 void wxFrame::InternalSetMenuBar()
@@ -778,25 +795,16 @@ bool wxFrame::OS2Create(
     FRAMECDATA                      vFrameCtlData;
     HWND                            hParent = NULLHANDLE;
     HWND                            hClient = NULLHANDLE;
+    HWND                            hFrame = NULLHANDLE;
     HWND                            hTitlebar = NULLHANDLE;
     HWND                            hHScroll = NULLHANDLE;
     HWND                            hVScroll = NULLHANDLE;
-    HWND                            hMenuBar = NULLHANDLE;
-    HWND                            hMenu1 = NULLHANDLE;
-    HWND                            hMenu2 = NULLHANDLE;
-    HWND                            hFrame = NULLHANDLE;
     SWP                             vSwp;
     SWP                             vSwpTitlebar;
     SWP                             vSwpVScroll;
     SWP                             vSwpHScroll;
-    SWP                             vSwpMenu;
-    RGB2                            vRgb;
 
     m_hDefaultIcon = (WXHICON) (wxSTD_FRAME_ICON ? wxSTD_FRAME_ICON : wxDEFAULT_FRAME_ICON);
-    memset(&vSwp, '\0', sizeof(SWP));
-    memset(&vSwpTitlebar, '\0', sizeof(SWP));
-    memset(&vSwpVScroll, '\0', sizeof(SWP));
-    memset(&vSwpHScroll, '\0', sizeof(SWP));
 
     if (pParent)
         hParent = GetWinHwnd(pParent);
@@ -881,6 +889,15 @@ bool wxFrame::OS2Create(
         return FALSE;
     }
 
+    hFrame = GetHwnd();
+
+    //
+    // Since under PM the controling window proc is associated with the client window handle
+    // not the frame's we have to perform the hook here in order to associated the client handle,
+    // not the frame's with the window object !
+    //
+
+    wxWndHook = this;
     //
     // Create the client window.  We must call the API from here rather than
     // the static base class create because we need a separate handle
@@ -899,6 +916,8 @@ bool wxFrame::OS2Create(
     {
         return FALSE;
     }
+
+    wxWndHook = NULL;
     //
     // Send anything to initialize the frame
     //
@@ -921,47 +940,26 @@ bool wxFrame::OS2Create(
                           ))
         return FALSE;
 
-    WinQueryWindowPos(hFrame, &vSwp);
+    WinQueryWindowPos(GetHwnd(), &vSwp);
+    hClient = WinWindowFromID(GetHwnd(), FID_CLIENT);
+    hTitlebar = WinWindowFromID(GetHwnd(), FID_TITLEBAR);
+    WinQueryWindowPos(hTitlebar, &vSwpTitlebar);
+    hHScroll = WinWindowFromID(GetHwnd(), FID_HORZSCROLL);
+    WinQueryWindowPos(hHScroll, &vSwpHScroll);
+    hVScroll = WinWindowFromID(GetHwnd(), FID_VERTSCROLL);
+    WinQueryWindowPos(hVScroll, &vSwpVScroll);
+    WinSetWindowPos( hClient
+                    ,HWND_TOP
+                    ,SV_CXSIZEBORDER/2
+                    ,(SV_CYSIZEBORDER/2) + vSwpHScroll.cy/2
+                    ,vSwp.cx - ((SV_CXSIZEBORDER + 1) + vSwpVScroll.cx)
+                    ,vSwp.cy - ((SV_CYSIZEBORDER + 1) + vSwpTitlebar.cy + vSwpHScroll.cy/2)
+                    ,SWP_SIZE | SWP_MOVE
+                   );
 
     //
     // Set the client window's background, otherwise it is transparent!
     //
-    wxColour                        vColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW);
-
-    vRgb.bRed   = (BYTE)vColour.Red();
-    vRgb.bGreen = (BYTE)vColour.Green();
-    vRgb.bBlue  = (BYTE)vColour.Blue();
-    WinSetPresParam( hClient
-                    ,PP_BACKGROUNDCOLOR
-                    ,(ULONG)sizeof(RGB2)
-                    ,(PVOID)&vRgb
-                   );
-    if (ulCreateFlags & FCF_TITLEBAR)
-    {
-        hTitlebar = WinWindowFromID(hFrame, FID_TITLEBAR);
-        WinQueryWindowPos(hTitlebar, &vSwpTitlebar);
-    }
-    if (ulCreateFlags & FCF_HORZSCROLL)
-    {
-        hHScroll = WinWindowFromID(hFrame, FID_HORZSCROLL);
-        WinQueryWindowPos(hHScroll, &vSwpHScroll);
-    }
-    if (ulCreateFlags & FCF_VERTSCROLL)
-    {
-        hVScroll = WinWindowFromID(hFrame, FID_VERTSCROLL);
-        WinQueryWindowPos(hVScroll, &vSwpVScroll);
-    }
-    if (!::WinSetWindowPos( hClient
-                           ,HWND_TOP
-                           ,SV_CXSIZEBORDER
-                           ,(SV_CYSIZEBORDER - 1) + vSwpHScroll.cy
-                           ,vSwp.cx - ((SV_CXSIZEBORDER * 2) + vSwpVScroll.cx)
-                           ,vSwp.cy - ((SV_CYSIZEBORDER * 2) + 1 + vSwpTitlebar.cy + vSwpHScroll.cy)
-                           ,SWP_SIZE | SWP_MOVE
-                          ))
-        return FALSE;
-    WinQueryWindowPos(hClient, &vSwp);
-    ::WinShowWindow(hClient, TRUE);
     return TRUE;
 } // end of wxFrame::OS2Create
 
index 3d9755066cd21e22d6f6fc5aa574abfc6e5cf7de..3ab6173a4b43b08c9ae52a13df9a885961277783 100644 (file)
@@ -324,6 +324,7 @@ bool wxMenu::DoInsertOrAppend(
         //
         // Menu is just a normal string (passed in data parameter)
         //
+        wxSetShortCutKey((wxChar*)pItem->GetText().c_str());
         vItem.afStyle |= MIS_TEXT;
         pData = (char*)pItem->GetText().c_str();
     }
@@ -730,6 +731,8 @@ WXHMENU wxMenuBar::Create()
                 return NULLHANDLE;
             }
 
+            m_menus[i]->m_vMenuData.iPosition = i;
+
             rc = (APIRET)::WinSendMsg(hMenuBar, MM_INSERTITEM, (MPARAM)&m_menus[i]->m_vMenuData, (MPARAM)m_titles[i].c_str());
             if (rc == MIT_MEMERROR || rc == MIT_ERROR)
             {
@@ -910,6 +913,8 @@ bool wxMenuBar::Append(
 
     wxCHECK_MSG(hSubmenu, FALSE, wxT("can't append invalid menu to menubar"));
 
+    wxSetShortCutKey((wxChar*)rTitle.c_str());
+
     wxString Title = TextToLabel(rTitle);
     if (!wxMenuBarBase::Append(pMenu, Title))
         return FALSE;
@@ -1069,3 +1074,23 @@ wxMenuItem* wxMenuBar::FindItem(
     return pItem;
 } // end of wxMenuBar::FindItem
 
+//
+// wxWindows' default shortcut identifier is WIN32's "&" but
+// OS2's is "~" so we have to change this and must watch for the
+// sequence, "&&" converting only the first one
+//
+void wxSetShortCutKey(
+  wxChar*                           zText
+)
+{
+    for (int i = 0; zText[i] != '\0'; i++)
+    {
+        if (zText[i] == '&')
+        {
+            zText[i] = '~';
+            if (zText[i+1] == '&')
+                i++;
+        }
+    }
+}
+
index 3ec349cf48ab05a3b322b9b1c588fe49e7a4d5be..2a899ef6186d5f7b6aad0a325d9d2414f56aa15a 100644 (file)
@@ -1674,12 +1674,12 @@ bool wxWindow::OS2ProcessMessage(
                 }
             }
         }
+        //
+        // Let Dialogs process
+        //
+        if (::WinSendMsg(pQMsg->hwnd, WM_QUERYDLGCODE, pQMsg, 0));
+            return TRUE;
     }
-    //
-    // Let Dialogs process
-    //
-    if (::WinSendMsg(pQMsg->hwnd, WM_QUERYDLGCODE, pQMsg, 0));
-        return TRUE;
 
 #if wxUSE_TOOLTIPS
     if ( m_tooltip )