From 938aa9c4618c9ed67fa791063681875106d3ef35 Mon Sep 17 00:00:00 2001 From: David Webster Date: Wed, 10 Apr 2002 22:29:32 +0000 Subject: [PATCH] Menuing and statusbar updates git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15087 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/os2/dc.h | 4 ++++ include/wx/os2/menu.h | 14 ++++++------ src/os2/dc.cpp | 46 +++++++++++++++++++++++++++++++++++++++ src/os2/dcclient.cpp | 10 +++++---- src/os2/menu.cpp | 50 +++++++++++++++++++++++++++++++------------ src/os2/menuitem.cpp | 2 ++ src/os2/wx23.def | 8 ++++++- 7 files changed, 109 insertions(+), 25 deletions(-) diff --git a/include/wx/os2/dc.h b/include/wx/os2/dc.h index 89377fd23c..87d00092a2 100644 --- a/include/wx/os2/dc.h +++ b/include/wx/os2/dc.h @@ -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() diff --git a/include/wx/os2/menu.h b/include/wx/os2/menu.h index fa781ad667..944f3617eb 100644 --- a/include/wx/os2/menu.h +++ b/include/wx/os2/menu.h @@ -13,10 +13,11 @@ #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) diff --git a/src/os2/dc.cpp b/src/os2/dc.cpp index 8c8d8a66a4..9912e149ce 100644 --- a/src/os2/dc.cpp +++ b/src/os2/dc.cpp @@ -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 ) diff --git a/src/os2/dcclient.cpp b/src/os2/dcclient.cpp index b8d62a043b..eef2ccd489 100644 --- a/src/os2/dcclient.cpp +++ b/src/os2/dcclient.cpp @@ -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( diff --git a/src/os2/menu.cpp b/src/os2/menu.cpp index 26a12fecfd..37898a1e55 100644 --- a/src/os2/menu.cpp +++ b/src/os2/menu.cpp @@ -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 diff --git a/src/os2/menuitem.cpp b/src/os2/menuitem.cpp index 1f208b9583..a5ad2a759f 100644 --- a/src/os2/menuitem.cpp +++ b/src/os2/menuitem.cpp @@ -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 diff --git a/src/os2/wx23.def b/src/os2/wx23.def index 994225ac86..29f32e4a8d 100644 --- a/src/os2/wx23.def +++ b/src/os2/wx23.def @@ -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() -- 2.45.2