]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/accel.cpp
added IsSizeDeferred() (part of patch 1199639)
[wxWidgets.git] / src / os2 / accel.cpp
index 1fdc45861f6aab2dee33396a19392c8bc4bdba16..34be76481503cfe9c93d0daf25e1c7500aaa367e 100644 (file)
@@ -89,8 +89,8 @@ wxAcceleratorTable::wxAcceleratorTable(
         wxFrame*                    pFrame = (wxFrame*)wxTheApp->GetTopWindow();
 
         ::WinSetAccelTable( vHabmain
-                           ,(HWND)pFrame->GetFrame()
                            ,hAccel
+                           ,(HWND)pFrame->GetFrame()
                           );
     }
     M_ACCELDATA->m_hAccel = hAccel;
@@ -105,7 +105,7 @@ extern int wxCharCodeWXToOS2(
 // Create from an array
 wxAcceleratorTable::wxAcceleratorTable(
   int                               n
-, wxAcceleratorEntry                vaEntries[]
+, const wxAcceleratorEntry          vaEntries[]
 )
 {
     int                             nAccelLength = ((sizeof(ACCEL) * n) + sizeof(ACCELTABLE));
@@ -120,26 +120,34 @@ wxAcceleratorTable::wxAcceleratorTable(
         USHORT                      uVirt = AF_CHAR;
 
         if (vaEntries[i].GetFlags() & wxACCEL_ALT)
+        {
             uVirt |= AF_ALT;
+            uVirt |= AF_VIRTUALKEY;
+        }
         if (vaEntries[i].GetFlags() & wxACCEL_SHIFT)
+        {
             uVirt |= AF_SHIFT;
+            uVirt |= AF_VIRTUALKEY;
+        }
         if (vaEntries[i].GetFlags() & wxACCEL_CTRL)
+        {
             uVirt |= AF_CONTROL;
+            uVirt |= AF_VIRTUALKEY;
+        }
 
-        bool                        bIsVirtual;
-        USHORT                      uKey = wxCharCodeWXToOS2( vaEntries[i].GetKeyCode()
-                                                             ,&bIsVirtual
-                                                            );
+        bool bIsVirtual;
+        USHORT uKey = (USHORT)wxCharCodeWXToOS2( vaEntries[i].GetKeyCode(),
+                                                 &bIsVirtual);
         if (bIsVirtual)
             uVirt = AF_CHAR | AF_VIRTUALKEY;
 
-        USHORT                      uCmd = vaEntries[i].GetCommand();
+        USHORT uCmd = (USHORT)vaEntries[i].GetCommand();
 
         pArr->aaccel[i].fs  = uVirt;
         pArr->aaccel[i].key = uKey;
         pArr->aaccel[i].cmd = uCmd;
     }
-    pArr->codepage = 437; // default to english Fix???
+    pArr->codepage = (USHORT)::WinQueryCp(wxTheApp->m_hMq);
     pArr->cAccel = (USHORT)n;
     M_ACCELDATA->m_hAccel = ::WinCreateAccelTable( vHabmain
                                                   ,pArr
@@ -149,11 +157,11 @@ wxAcceleratorTable::wxAcceleratorTable(
         //
         // If we have accelerators the top window is the frame
         //
-        wxFrame*                    pFrame = (wxFrame*)wxTheApp->GetTopWindow();
+        wxFrame* pFrame = (wxFrame*)wxTheApp->GetTopWindow();
 
         ::WinSetAccelTable( vHabmain
-                           ,(HWND)pFrame->GetFrame()
                            ,M_ACCELDATA->m_hAccel
+                           ,(HWND)pFrame->GetFrame()
                           );
     }
 
@@ -187,11 +195,52 @@ bool wxAcceleratorTable::Translate(
 ) const
 {
     PQMSG                           pMsg = (PQMSG)pWxmsg;
-
-    return Ok() && ::WinTranslateAccel( vHabmain
-                                       ,(HWND)hWnd
-                                       ,GetHaccel()
-                                       ,pMsg
-                                       );
+    BOOL                            rc = FALSE;
+
+    rc = ::WinTranslateAccel( vHabmain
+                             ,(HWND)hWnd
+                             ,GetHaccel()
+                             ,pMsg
+                            );
+    return (Ok() && rc);
 } // end of wxAcceleratorTable::Translate
 
+// ---------------------------------------------------------------------------
+// function for translating labels
+// ---------------------------------------------------------------------------
+
+wxString wxPMTextToLabel( const wxString& rsTitle )
+{
+    wxString      sTitle;
+    const wxChar* zPc;
+
+    if (rsTitle.empty())
+        return(sTitle);
+
+    for (zPc = rsTitle.c_str(); *zPc != wxT('\0'); zPc++)
+    {
+        if (*zPc == wxT('&'))
+        {
+            if (*(zPc + 1) == wxT('&'))
+            {
+                zPc++;
+                sTitle << wxT('&');
+            }
+            else
+                sTitle << wxT('~');
+        }
+        else
+        {
+            if ( *zPc == wxT('~'))
+            {
+                //
+                // Tildes must be doubled to prevent them from being
+                // interpreted as accelerator character prefix by PM ???
+                //
+                sTitle << *zPc;
+            }
+            sTitle << *zPc;
+        }
+    }
+    return(sTitle);
+} // end of wxPMTextToLabel