]> git.saurik.com Git - wxWidgets.git/commitdiff
Menuing and statusbar updates
authorDavid Webster <Dave.Webster@bhmi.com>
Wed, 10 Apr 2002 22:29:32 +0000 (22:29 +0000)
committerDavid Webster <Dave.Webster@bhmi.com>
Wed, 10 Apr 2002 22:29:32 +0000 (22:29 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15087 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/os2/dc.h
include/wx/os2/menu.h
src/os2/dc.cpp
src/os2/dcclient.cpp
src/os2/menu.cpp
src/os2/menuitem.cpp
src/os2/wx23.def

index 89377fd23c7c44c3257e10ecd85a8cc7f22e37b0..87d00092a235072983cef044010bb0ca1f1aa40a 100644 (file)
@@ -333,6 +333,10 @@ protected:
                                ,int     nFillStyle = wxODDEVEN_RULE
                               );
 
+#if wxUSE_PALETTE
+    void DoSelectPalette(bool bRealize = FALSE);
+    void InitializePalette(void);
+#endif // wxUSE_PALETTE
 
     //
     // common part of DoDrawText() and DoDrawRotatedText()
index fa781ad66728e4ffc79820f9f90fe001f88fc2a3..944f3617ebdc0df98a86ec84afb8a0e248aa0d9a 100644 (file)
 #define _WX_MENU_H_
 
 #if wxUSE_ACCEL
-    #include "wx/accel.h"
-    #include "wx/dynarray.h"
+//    #include "wx/accel.h"
+//    #include "wx/list.h"        // for "template" list classes
+//    #include "wx/dynarray.h"
 
-    WX_DEFINE_EXPORTED_ARRAY(wxAcceleratorEntry *, wxAcceleratorArray);
+//    WX_DECLARE_EXPORTED_LIST(wxAcceleratorEntry, wxAcceleratorList);
 #endif // wxUSE_ACCEL
 
 class WXDLLEXPORT wxFrame;
@@ -99,8 +100,8 @@ public:
     //
     // Called by wxMenuBar to build its accel table from the accels of all menus
     //
-    bool   HasAccels(void) const { return !m_vAccels.IsEmpty(); }
-    size_t GetAccelCount(void) const { return m_vAccels.GetCount(); }
+    bool   HasAccels(void) const { return m_vAccels[0] != NULL; }
+    size_t GetAccelCount(void) const { return (size_t)m_nNextAccel; }
     size_t CopyAccels(wxAcceleratorEntry* pAccels) const;
 
     //
@@ -170,7 +171,8 @@ private:
     //
     // The accelerators for our menu items
     //
-    wxAcceleratorArray              m_vAccels;
+    wxAcceleratorEntry*             m_vAccels[128];
+    int                             m_nNextAccel;
 #endif // wxUSE_ACCEL
 
     DECLARE_DYNAMIC_CLASS(wxMenu)
index 8c8d8a66a4781c827fc546f915a95e75e41e2015..9912e149cecb2426c6488abf65d80daa23f775f7 100644 (file)
@@ -1366,6 +1366,52 @@ void wxDC::DoDrawRotatedText(
 // set GDI objects
 // ---------------------------------------------------------------------------
 
+void wxDC::DoSelectPalette(
+  bool                              bRealize
+)
+{
+    //
+    // Set the old object temporarily, in case the assignment deletes an object
+    // that's not yet selected out.
+    //
+    if (m_hOldPalette)
+    {
+        m_hOldPalette = 0;
+    }
+
+    if (m_palette.Ok())
+    {
+        HPALETTE                    hOldPal;
+
+        hOldPal = ::GpiSelectPalette((HDC) m_hPS, (HPALETTE) m_palette.GetHPALETTE());
+        if (!m_hOldPalette)
+            m_hOldPalette = (WXHPALETTE)hOldPal;
+    }
+} // end of wxDC::DoSelectPalette
+
+void wxDC::InitializePalette()
+{
+    if (wxDisplayDepth() <= 8 )
+    {
+        //
+        // Look for any window or parent that has a custom palette. If any has
+        // one then we need to use it in drawing operations
+        //
+        wxWindow*                   pWin = m_pCanvas->GetAncestorWithCustomPalette();
+
+        m_hasCustomPalette = pWin && pWin->HasCustomPalette();
+        if (m_hasCustomPalette)
+        {
+            m_palette = pWin->GetPalette();
+
+            //
+            // turn on PM translation for this palette
+            //
+            DoSelectPalette();
+        }
+    }
+} // end of wxDC::InitializePalette
+
 void wxDC::SetPalette(
   const wxPalette&                  rPalette
 )
index b8d62a043b90a2280122cde492fccd47603c7e9f..eef2ccd489b602e367f12989c776b874d948a1b4 100644 (file)
@@ -144,10 +144,6 @@ void wxWindowDC::InitDC()
 {
     wxColour                        vColor;
 
-    vColor.InitFromName("BLACK");
-    m_pen.SetColour(vColor);
-    vColor.Set("WHITE");
-    m_brush.SetColour(vColor);
     //
     // The background mode is only used for text background and is set in
     // DrawText() to OPAQUE as required, otherwise always TRANSPARENT,
@@ -158,6 +154,12 @@ void wxWindowDC::InitDC()
     // Default bg colour is pne of the window
     //
     SetBackground(wxBrush(m_pCanvas->GetBackgroundColour(), wxSOLID));
+
+    vColor.InitFromName("BLACK");
+    m_pen.SetColour(vColor);
+    vColor.Set("WHITE");
+    m_brush.SetColour(vColor);
+    InitializePalette();
 } // end of wxWindowDC::InitDC
 
 void wxWindowDC::DoGetSize(
index 26a12fecfdc421b20e01b294f38d9e57e2fc4c6f..37898a1e558bde4fea195e0688c32e22cc7d5dec 100644 (file)
@@ -151,6 +151,9 @@ void wxMenu::Init()
               );
         AppendSeparator();
     }
+    for (int i = 0; i < 128; i++)
+        m_vAccels[i] = NULL;
+    m_nNextAccel = 0;
 } // end of wxMenu::Init
 
 //
@@ -175,7 +178,15 @@ wxMenu::~wxMenu()
     // Delete accels
     //
 #if (!(defined(__VISAGECPP__) && (__IBMCPP__ < 400 || __IBMC__ < 400 )))
-    WX_CLEAR_ARRAY(m_vAccels);
+    for (int i = 0; i < 128; i++)
+    {
+        if (m_vAccels[i])
+        {
+            delete m_vAccels[i];
+            m_vAccels[i] = NULL;
+        }
+    }
+//    WX_CLEAR_ARRAY(m_vAccels);
 #endif
 #endif // wxUSE_ACCEL
 } // end of wxMenu::~wxMenu
@@ -201,12 +212,15 @@ int wxMenu::FindAccel(
 ) const
 {
     size_t                          n;
-    size_t                          nCount = m_vAccels.GetCount();
+//    size_t                          nCount = m_vAccels.GetCount();
 
-    for (n = 0; n < nCount; n++)
+    for (n = 0; n < m_nNextAccel; n++)
     {
-        if (m_vAccels[n]->m_command == nId)
-            return n;
+        if (m_vAccels[n] != NULL)
+        {
+            if (m_vAccels[n]->m_command == nId)
+                return n;
+        }
     }
     return wxNOT_FOUND;
 } // end of wxMenu::FindAccel
@@ -238,7 +252,7 @@ void wxMenu::UpdateAccel(
         //
         // Find the old one
         //
-        int                             n = FindAccel(pItem->GetId());
+        size_t                      n = FindAccel(pItem->GetId());
 
         if (n == wxNOT_FOUND)
         {
@@ -246,7 +260,15 @@ void wxMenu::UpdateAccel(
             // No old, add new if any
             //
             if (pAccel)
-                m_vAccels.Add(pAccel);
+            {
+                if (m_nNextAccel < 128)
+                {
+                    m_vAccels[m_nNextAccel] = pAccel;
+                    m_nNextAccel++;
+                }
+                else
+                    return;     // skipping RebuildAccelTable() below
+            }
             else
                 return;     // skipping RebuildAccelTable() below
         }
@@ -255,12 +277,11 @@ void wxMenu::UpdateAccel(
             //
             // Replace old with new or just remove the old one if no new
             //
-            delete                      m_vAccels[n];
+            delete m_vAccels[n];
+            m_vAccels[n] = NULL;
 
             if (pAccel)
                 m_vAccels[n] = pAccel;
-            else
-                m_vAccels.RemoveAt(n);
         }
 
         if (IsAttached())
@@ -280,6 +301,10 @@ bool wxMenu::DoInsertOrAppend(
 , size_t                            nPos
 )
 {
+    wxMenu*                         pSubmenu = pItem->GetSubMenu();
+    MENUITEM&                       rItem = (pSubmenu != NULL)?pSubmenu->m_vMenuData:
+                                            pItem->m_vMenuData;
+
     ERRORID                         vError;
     wxString                        sError;
     char                            zMsg[128];
@@ -292,9 +317,6 @@ bool wxMenu::DoInsertOrAppend(
     // MENUITEM for submenus as required by ::MM_INSERTITEM message API
     //
 
-    wxMenu*                         pSubmenu = pItem->GetSubMenu();
-    MENUITEM&                       rItem = (pSubmenu != NULL)?pSubmenu->m_vMenuData:
-                                            pItem->m_vMenuData;
     if(pSubmenu != NULL)
     {
         wxASSERT_MSG(pSubmenu->GetHMenu(), wxT("invalid submenu"));
@@ -521,7 +543,7 @@ wxMenuItem* wxMenu::DoRemove(
     if (n != wxNOT_FOUND)
     {
         delete m_vAccels[n];
-        m_vAccels.RemoveAt(n);
+        m_vAccels[n] = NULL;
     }
 
 #endif // wxUSE_ACCEL
index 1f208b95836ee6c202e6bba7ec1f5e63923fd823..a5ad2a759f5a3429c572d6475e18556f4b64541d 100644 (file)
@@ -153,6 +153,8 @@ wxMenuItem::wxMenuItem(
 #endif // owner drawn
 {
     wxASSERT_MSG(pParentMenu != NULL, wxT("a menu item should have a parent"));
+    memset(&m_vMenuData, '\0', sizeof(m_vMenuData));
+    m_vMenuData.id = (USHORT)nId;
 
     Init();
 } // end of wxMenuItem::wxMenuItem
index 994225ac86c23155de7b8faddcb9f8213e0c2070..29f32e4a8de7b03babf7267a86a78e7ab450d6bb 100644 (file)
@@ -4,7 +4,7 @@ DATA MULTIPLE NONSHARED READWRITE LOADONCALL
 CODE LOADONCALL
 
 EXPORTS
-;From library:  H:\Dev\Wx2\WxWindows\lib\wx.lib
+;From library:  H:\DEV\Wx2\WxWindows\lib\wx.lib
   ;From object file:  dummy.cpp
     ;PUBDEFs (Symbols available from object file):
       wxDummyChar
@@ -12133,6 +12133,8 @@ EXPORTS
       QueryTextBkColor__FUl
       ;wxDC::SelectOldObjects(unsigned long)
       SelectOldObjects__4wxDCFUl
+      ;wxDC::DoSelectPalette(unsigned long)
+      DoSelectPalette__4wxDCFUl
       ;SetBkMode(unsigned long,int)
       SetBkMode__FUli
       ;wxDC::DoSetClippingRegion(int,int,int,int)
@@ -12155,6 +12157,8 @@ EXPORTS
       DoDrawIcon__4wxDCFRC6wxIconiT2
       ;wxDC::StartPage()
       StartPage__4wxDCFv
+      ;wxDC::InitializePalette()
+      InitializePalette__4wxDCFv
       ;wxDC::GetCharWidth() const
       GetCharWidth__4wxDCCFv
       ;wxDC::DoDrawRotatedText(const wxString&,int,int,double)
@@ -14276,6 +14280,8 @@ EXPORTS
       OnCut__10wxTextCtrlFR14wxCommandEvent
       ;wxTextCtrl::OnCopy(wxCommandEvent&)
       OnCopy__10wxTextCtrlFR14wxCommandEvent
+      ;wxTextCtrl::EmulateKeyPress(const wxKeyEvent&)
+      EmulateKeyPress__10wxTextCtrlFRC10wxKeyEvent
       ;wxConstructorForwxTextCtrl()
       wxConstructorForwxTextCtrl__Fv
       ;wxTextCtrl::wxTextCtrl()