From 598d8cacefaa185a962ebc39d31533410692c56b Mon Sep 17 00:00:00 2001 From: David Webster Date: Mon, 15 Apr 2002 03:31:42 +0000 Subject: [PATCH] Bitmap and menu updates git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15139 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/os2/menu.h | 19 +++++---- include/wx/os2/menuitem.h | 12 +++++- include/wx/os2/window.h | 2 +- src/os2/accel.cpp | 4 +- src/os2/combobox.cpp | 10 ++++- src/os2/frame.cpp | 12 ++---- src/os2/menu.cpp | 86 +++++++++++++++++---------------------- src/os2/menuitem.cpp | 67 +++++++++++++++--------------- src/os2/window.cpp | 23 +++-------- src/os2/wx23.def | 24 +++++++---- 10 files changed, 130 insertions(+), 129 deletions(-) diff --git a/include/wx/os2/menu.h b/include/wx/os2/menu.h index 944f3617eb..14205d6759 100644 --- a/include/wx/os2/menu.h +++ b/include/wx/os2/menu.h @@ -13,11 +13,11 @@ #define _WX_MENU_H_ #if wxUSE_ACCEL -// #include "wx/accel.h" -// #include "wx/list.h" // for "template" list classes -// #include "wx/dynarray.h" + #include "wx/accel.h" + #include "wx/list.h" // for "template" list classes + #include "wx/dynarray.h" -// WX_DECLARE_EXPORTED_LIST(wxAcceleratorEntry, wxAcceleratorList); + WX_DEFINE_EXPORTED_ARRAY(wxAcceleratorEntry *, wxAcceleratorArray); #endif // wxUSE_ACCEL class WXDLLEXPORT wxFrame; @@ -78,6 +78,8 @@ public: // Implementation only from now on // ------------------------------- // + virtual void Attach(wxMenuBarBase* pMenubar); + bool OS2Command( WXUINT uParam ,WXWORD wId ); @@ -100,8 +102,8 @@ public: // // Called by wxMenuBar to build its accel table from the accels of all menus // - bool HasAccels(void) const { return m_vAccels[0] != NULL; } - size_t GetAccelCount(void) const { return (size_t)m_nNextAccel; } + bool HasAccels(void) const { return m_vAccels.IsEmpty(); } + size_t GetAccelCount(void) const { return m_vAccels.GetCount(); } size_t CopyAccels(wxAcceleratorEntry* pAccels) const; // @@ -160,7 +162,7 @@ private: // // The helper variable for creating unique IDs. // - static USHORT m_nextMenuId; + static USHORT m_nextMenuId; // // The position of the first item in the current radio group or -1 @@ -171,8 +173,7 @@ private: // // The accelerators for our menu items // - wxAcceleratorEntry* m_vAccels[128]; - int m_nNextAccel; + wxAcceleratorArray m_vAccels; #endif // wxUSE_ACCEL DECLARE_DYNAMIC_CLASS(wxMenu) diff --git a/include/wx/os2/menuitem.h b/include/wx/os2/menuitem.h index 00027ee3fd..1f0275347c 100644 --- a/include/wx/os2/menuitem.h +++ b/include/wx/os2/menuitem.h @@ -49,7 +49,7 @@ public: ,int nId = wxID_SEPARATOR ,const wxString& rStrName = "" ,const wxString& rWxHelp = "" - ,wxItemKind kind = wxITEM_NORMAL + ,wxItemKind eKind = wxITEM_NORMAL ,wxMenu* pSubMenu = NULL ); @@ -88,6 +88,9 @@ public: // int GetRealId(void) const; + // + // Mark item as belonging to the given radio group + // void SetAsRadioGroupStart(void); void SetRadioGroupStart(int nStart); void SetRadioGroupEnd(int nEnd); @@ -110,8 +113,13 @@ private: { int m_nStart; int m_nEnd; - } m_vRadioGroup; + } m_vRadioGroup; + + // + // Does this item start a radio group? + // bool m_bIsRadioGroupStart; + DECLARE_DYNAMIC_CLASS(wxMenuItem) }; // end of CLASS wxMenuItem diff --git a/include/wx/os2/window.h b/include/wx/os2/window.h index 318f7c5801..64e0c1e674 100644 --- a/include/wx/os2/window.h +++ b/include/wx/os2/window.h @@ -405,7 +405,7 @@ public: ,int nY ,WXUINT uFlags ); - bool HandleChar( WXDWORD wParam + bool HandleChar( WXWPARAM wParam ,WXLPARAM lParam ,bool bIsASCII = FALSE ); diff --git a/src/os2/accel.cpp b/src/os2/accel.cpp index 8e1c6f43b6..802a3867e4 100644 --- a/src/os2/accel.cpp +++ b/src/os2/accel.cpp @@ -90,7 +90,7 @@ wxAcceleratorTable::wxAcceleratorTable( ::WinSetAccelTable( vHabmain ,hAccel - ,(HWND)pFrame->GetHWND() + ,(HWND)pFrame->GetFrame() ); } M_ACCELDATA->m_hAccel = hAccel; @@ -162,7 +162,7 @@ wxAcceleratorTable::wxAcceleratorTable( ::WinSetAccelTable( vHabmain ,M_ACCELDATA->m_hAccel - ,(HWND)pFrame->GetHWND() + ,(HWND)pFrame->GetFrame() ); } diff --git a/src/os2/combobox.cpp b/src/os2/combobox.cpp index d1861e80f0..927325f758 100644 --- a/src/os2/combobox.cpp +++ b/src/os2/combobox.cpp @@ -403,7 +403,7 @@ bool wxComboBox::ProcessEditMsg( switch(vFlag) { case KC_CHAR: - return (HandleChar( SHORT1FROMMP(wParam) + return (HandleChar( wParam ,lParam ,TRUE /* isASCII */ )); @@ -419,6 +419,13 @@ bool wxComboBox::ProcessEditMsg( )); } break; + + case WM_SETFOCUS: + if (SHORT1FROMMP((MPARAM)lParam) == TRUE) + return(HandleSetFocus((WXHWND)(HWND)wParam)); + else + return(HandleKillFocus((WXHWND)(HWND)wParam)); + break; } return FALSE; } // end of WinGuiBase_CComboBox::ProcessEditMsg @@ -440,6 +447,7 @@ MRESULT EXPENTRY wxComboEditWndProc( // // Forward some messages to the combobox // + case WM_SETFOCUS: case WM_CHAR: { wxComboBox* pCombo = wxDynamicCast( pWin diff --git a/src/os2/frame.cpp b/src/os2/frame.cpp index f0a4438e16..bca65d8c35 100644 --- a/src/os2/frame.cpp +++ b/src/os2/frame.cpp @@ -1072,14 +1072,10 @@ bool wxFrame::HandleSize( PositionToolBar(); #endif // wxUSE_TOOLBAR - wxSizeEvent vEvent( wxSize( nX - ,nY - ) - ,m_windowId - ); - - vEvent.SetEventObject(this); - bProcessed = GetEventHandler()->ProcessEvent(vEvent); + bProcessed = wxWindow::HandleSize( nX + ,nY + ,nId + ); } return bProcessed; } // end of wxFrame::HandleSize diff --git a/src/os2/menu.cpp b/src/os2/menu.cpp index 37898a1e55..5f4ba30bb4 100644 --- a/src/os2/menu.cpp +++ b/src/os2/menu.cpp @@ -113,6 +113,7 @@ static wxString TextToLabel(const wxString& rTitle) void wxMenu::Init() { m_bDoBreak = FALSE; + m_nStartRadioGroup = -1; // // Create the menu (to be used as a submenu or a popup) @@ -151,9 +152,6 @@ void wxMenu::Init() ); AppendSeparator(); } - for (int i = 0; i < 128; i++) - m_vAccels[i] = NULL; - m_nNextAccel = 0; } // end of wxMenu::Init // @@ -177,17 +175,7 @@ wxMenu::~wxMenu() // // Delete accels // -#if (!(defined(__VISAGECPP__) && (__IBMCPP__ < 400 || __IBMC__ < 400 ))) - 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 + WX_CLEAR_ARRAY(m_vAccels); #endif // wxUSE_ACCEL } // end of wxMenu::~wxMenu @@ -197,31 +185,26 @@ void wxMenu::Break() m_bDoBreak = TRUE; } // end of wxMenu::Break -#if wxUSE_ACCEL - -void wxMenu::EndRadioGroup() +void wxMenu::Attach( + wxMenuBarBase* pMenubar +) { - // - // We're not inside a radio group any longer - // - m_nStartRadioGroup = -1; -} // end of wxMenu::EndRadioGroup + wxMenuBase::Attach(pMenubar); + EndRadioGroup(); +} // end of wxMenu::Break; + +#if wxUSE_ACCEL int wxMenu::FindAccel( int nId ) const { size_t n; -// size_t nCount = m_vAccels.GetCount(); + size_t nCount = m_vAccels.GetCount(); - for (n = 0; n < m_nNextAccel; n++) - { - if (m_vAccels[n] != NULL) - { - if (m_vAccels[n]->m_command == nId) - return n; - } - } + for (n = 0; n < nCount; n++) + if (m_vAccels[n]->m_command == nId) + return n; return wxNOT_FOUND; } // end of wxMenu::FindAccel @@ -246,6 +229,7 @@ void wxMenu::UpdateAccel( // Find the (new) accel for this item // wxAcceleratorEntry* pAccel = wxGetAccelFromString(pItem->GetText()); + if (pAccel) pAccel->m_command = pItem->GetId(); @@ -260,17 +244,9 @@ void wxMenu::UpdateAccel( // No old, add new if any // if (pAccel) - { - if (m_nNextAccel < 128) - { - m_vAccels[m_nNextAccel] = pAccel; - m_nNextAccel++; - } - else - return; // skipping RebuildAccelTable() below - } + m_vAccels.Add(pAccel); else - return; // skipping RebuildAccelTable() below + return; } else { @@ -278,10 +254,10 @@ void wxMenu::UpdateAccel( // Replace old with new or just remove the old one if no new // delete m_vAccels[n]; - m_vAccels[n] = NULL; - if (pAccel) m_vAccels[n] = pAccel; + else + m_vAccels.RemoveAt(n); } if (IsAttached()) @@ -437,6 +413,14 @@ bool wxMenu::DoInsertOrAppend( return FALSE; } // end of wxMenu::DoInsertOrAppend +void wxMenu::EndRadioGroup() +{ + // + // We're not inside a radio group any longer + // + m_nStartRadioGroup = -1; +} // end of wxMenu::EndRadioGroup + bool wxMenu::DoAppend( wxMenuItem* pItem ) @@ -473,6 +457,7 @@ bool wxMenu::DoAppend( // We need to update its end item // pItem->SetRadioGroupStart(m_nStartRadioGroup); + wxMenuItemList::Node* pNode = GetMenuItems().Item(m_nStartRadioGroup); if (pNode) @@ -489,16 +474,20 @@ bool wxMenu::DoAppend( { EndRadioGroup(); } + if (!wxMenuBase::DoAppend(pItem) || !DoInsertOrAppend(pItem)) { return FALSE; } if (bCheck) { + // + // Check the item initially + // pItem->Check(TRUE); } return TRUE; -} // end of wxMenu::DoInsert +} // end of wxMenu::DoAppend bool wxMenu::DoInsert( size_t nPos @@ -509,7 +498,8 @@ bool wxMenu::DoInsert( ,pItem) && DoInsertOrAppend( pItem ,nPos - )); + ) + ); } // end of wxMenu::DoInsert wxMenuItem* wxMenu::DoRemove( @@ -543,7 +533,7 @@ wxMenuItem* wxMenu::DoRemove( if (n != wxNOT_FOUND) { delete m_vAccels[n]; - m_vAccels[n] = NULL; + m_vAccels.RemoveAt(n); } #endif // wxUSE_ACCEL @@ -1120,7 +1110,7 @@ void wxMenuBar::Attach( wxFrame* pFrame ) { - wxASSERT_MSG( !IsAttached(), wxT("menubar already attached!") ); + wxMenuBarBase::Attach(pFrame); #if wxUSE_ACCEL RebuildAccelTable(); @@ -1128,8 +1118,8 @@ void wxMenuBar::Attach( // Ensure the accelerator table is set to the frame (not the client!) // if (!::WinSetAccelTable( vHabmain - ,(HWND)pFrame->GetHWND() ,m_vAccelTable.GetHACCEL() + ,(HWND)pFrame->GetFrame() )) wxLogLastError("WinSetAccelTable"); #endif // wxUSE_ACCEL diff --git a/src/os2/menuitem.cpp b/src/os2/menuitem.cpp index a5ad2a759f..574fea6166 100644 --- a/src/os2/menuitem.cpp +++ b/src/os2/menuitem.cpp @@ -236,9 +236,10 @@ wxString wxMenuItemBase::GetLabelFromText( return label; } -// radio group stuff +// +// Radio group stuff // ----------------- - +// void wxMenuItem::SetAsRadioGroupStart() { m_bIsRadioGroupStart = TRUE; @@ -248,23 +249,23 @@ void wxMenuItem::SetRadioGroupStart( int nStart ) { - wxASSERT_MSG( !m_bIsRadioGroupStart, - _T("should only be called for the next radio items") ); + wxASSERT_MSG( !m_bIsRadioGroupStart + ,_T("should only be called for the next radio items") + ); m_vRadioGroup.m_nStart = nStart; -} // end of wxMenuItem::SetRadioGroupStart +} // wxMenuItem::SetRadioGroupStart void wxMenuItem::SetRadioGroupEnd( int nEnd ) { - wxASSERT_MSG( m_bIsRadioGroupStart, - _T("should only be called for the first radio item") ); - + wxASSERT_MSG( m_bIsRadioGroupStart + ,_T("should only be called for the first radio item") + ); m_vRadioGroup.m_nEnd = nEnd; } // end of wxMenuItem::SetRadioGroupEnd - // change item state // ----------------- @@ -306,7 +307,8 @@ void wxMenuItem::Check( return; HMENU hMenu = GetHmenuOf(m_parentMenu); - if ( GetKind() == wxITEM_RADIO ) + + if (GetKind() == wxITEM_RADIO) { // // It doesn't make sense to uncheck a radio item - what would this do? @@ -319,23 +321,26 @@ void wxMenuItem::Check( // const wxMenuItemList& rItems = m_parentMenu->GetMenuItems(); int nPos = rItems.IndexOf(this); - int nStart; - int nEnd; - wxCHECK_RET( nPos != wxNOT_FOUND, - _T("menuitem not found in the menu items list?") ); + wxCHECK_RET( nPos != wxNOT_FOUND + ,_T("menuitem not found in the menu items list?") + ); // // Get the radio group range // + int nStart; + int nEnd; if (m_bIsRadioGroupStart) { - // we already have all information we need + // + // We already have all information we need + // nStart = nPos; - nEnd = m_vRadioGroup.m_nEnd; + nEnd = m_vRadioGroup.m_nEnd; } - else // Next radio group item + else // next radio group item { // // Get the radio group end from the start item @@ -351,26 +356,22 @@ void wxMenuItem::Check( for (int n = nStart; n <= nEnd && pNode; n++) { - if (n != nPos) - { - pNode->GetData()->m_isChecked = FALSE; - } - if (n == nPos) { - bOk = (bool)::WinSendMsg( hMenu - ,MM_SETITEMATTR - ,MPFROM2SHORT(n, TRUE) - ,MPFROM2SHORT(MIA_CHECKED, MIA_CHECKED) - ); + ::WinSendMsg( hMenu + ,MM_SETITEMATTR + ,MPFROM2SHORT(n, TRUE) + ,MPFROM2SHORT(MIA_CHECKED, MIA_CHECKED) + ); } - else + if (n != nPos) { - bOk = (bool)::WinSendMsg( hMenu - ,MM_SETITEMATTR - ,MPFROM2SHORT(n, TRUE) - ,MPFROM2SHORT(MIA_CHECKED, FALSE) - ); + pNode->GetData()->m_isChecked = FALSE; + ::WinSendMsg( hMenu + ,MM_SETITEMATTR + ,MPFROM2SHORT(n, TRUE) + ,MPFROM2SHORT(MIA_CHECKED, FALSE) + ); } pNode = pNode->GetNext(); } diff --git a/src/os2/window.cpp b/src/os2/window.cpp index 3e106c6c6a..0e3bf3063f 100644 --- a/src/os2/window.cpp +++ b/src/os2/window.cpp @@ -2759,20 +2759,7 @@ MRESULT wxWindowOS2::OS2WindowProc( break; default: - if (m_bLastKeydownProcessed) - { - // - // The key was handled in the EVT_KEY_DOWN and handling - // a key in an EVT_KEY_DOWN handler is meant, by - // design, to prevent EVT_CHARs from happening - // - m_bLastKeydownProcessed = FALSE; - bProcessed = TRUE; - } - else // do generate a CHAR event - { - bProcessed = HandleChar((WXDWORD)wParam, lParam); - } + bProcessed = HandleChar(wParam, lParam); } break; } @@ -2790,7 +2777,7 @@ MRESULT wxWindowOS2::OS2WindowProc( } else // do generate a CHAR event { - bProcessed = HandleChar((WXDWORD)wParam, lParam, TRUE); + bProcessed = HandleChar(wParam, lParam, TRUE); break; } } @@ -4050,7 +4037,7 @@ wxKeyEvent wxWindowOS2::CreateKeyEvent( // WM_KEYDOWN one // bool wxWindowOS2::HandleChar( - WXDWORD wParam + WXWPARAM wParam , WXLPARAM lParam , bool isASCII ) @@ -4073,7 +4060,7 @@ bool wxWindowOS2::HandleChar( // // If 1 -> 26, translate to CTRL plus a letter. // - vId = wParam; + vId = (int)wParam; if ((vId > 0) && (vId < 27)) { switch (vId) @@ -4098,7 +4085,7 @@ bool wxWindowOS2::HandleChar( } else // we're called from WM_KEYDOWN { - vId = wxCharCodeOS2ToWX(wParam); + vId = wxCharCodeOS2ToWX((int)wParam); if (vId == 0) return FALSE; } diff --git a/src/os2/wx23.def b/src/os2/wx23.def index 29f32e4a8d..c4f7f11547 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: F:\DEV\WX2\WXWINDOWS\LIB\WX.lib ;From object file: dummy.cpp ;PUBDEFs (Symbols available from object file): wxDummyChar @@ -1709,6 +1709,8 @@ EXPORTS wxConstructorForwxSysColourChangedEvent__Fv ;wxConstructorForwxNavigationKeyEvent() wxConstructorForwxNavigationKeyEvent__Fv + ;wxConstructorForwxMouseCaptureChangedEvent() + wxConstructorForwxMouseCaptureChangedEvent__Fv ;wxConstructorForwxHelpEvent() wxConstructorForwxHelpEvent__Fv ;wxEvtHandler::~wxEvtHandler() @@ -1879,6 +1881,8 @@ EXPORTS sm_classwxScrollWinEvent__16wxScrollWinEvent ;wxNcPaintEvent::sm_classwxNcPaintEvent sm_classwxNcPaintEvent__14wxNcPaintEvent + ;wxMouseCaptureChangedEvent::sm_classwxMouseCaptureChangedEvent + sm_classwxMouseCaptureChangedEvent__26wxMouseCaptureChangedEvent ;wxIdleEvent::sm_classwxIdleEvent sm_classwxIdleEvent__11wxIdleEvent ;wxDropFilesEvent::sm_classwxDropFilesEvent @@ -1921,7 +1925,7 @@ EXPORTS wxEVT_NC_LEFT_DCLICK wxEVT_INIT_DIALOG wxEVT_COMMAND_SET_FOCUS - ;From object file: H:\DEV\WX2\WXWINDOWS\src\common\extended.c + ;From object file: F:\DEV\WX2\WXWINDOWS\src\common\extended.c ;PUBDEFs (Symbols available from object file): ConvertToIeeeExtended ConvertFromIeeeExtended @@ -6023,7 +6027,7 @@ EXPORTS Read32__17wxTextInputStreamFv ;wxTextInputStream::SkipIfEndOfLine(char) SkipIfEndOfLine__17wxTextInputStreamFc - ;From object file: H:\DEV\WX2\WXWINDOWS\src\common\unzip.c + ;From object file: F:\DEV\WX2\WXWINDOWS\src\common\unzip.c ;PUBDEFs (Symbols available from object file): unzReadCurrentFile unzGetCurrentFileInfo @@ -7706,12 +7710,16 @@ EXPORTS SetFilterIndex__16wxGenericDirCtrlFi ;wxDirFilterListCtrl::FillFilterList(const wxString&,int) FillFilterList__19wxDirFilterListCtrlFRC8wxStringi + ;wxGenericDirCtrl::ReCreateTree() + ReCreateTree__16wxGenericDirCtrlFv ;wxGenericDirCtrl::SetupSections() SetupSections__16wxGenericDirCtrlFv ;wxGenericDirCtrl::ShowHidden(unsigned long) ShowHidden__16wxGenericDirCtrlFUl ;wxGenericDirCtrl::OnCollapseItem(wxTreeEvent&) OnCollapseItem__16wxGenericDirCtrlFR11wxTreeEvent + ;wxGenericDirCtrl::CollapseDir(wxTreeItemId) + CollapseDir__16wxGenericDirCtrlF12wxTreeItemId ;wxDirItemData::HasSubDirs() const HasSubDirs__13wxDirItemDataCFv ;wxGenericDirCtrl::GetPath() const @@ -13246,10 +13254,12 @@ EXPORTS OS2Command__6wxMenuFUiUs ;wxMenuBar::EnableTop(unsigned int,unsigned long) EnableTop__9wxMenuBarFUiUl - ;wxMenu::DoAppend(wxMenuItem*) - DoAppend__6wxMenuFP10wxMenuItem + ;wxMenu::Attach(wxMenuBarBase*) + Attach__6wxMenuFP13wxMenuBarBase ;wxMenu::DoRemove(wxMenuItem*) DoRemove__6wxMenuFP10wxMenuItem + ;wxMenu::DoAppend(wxMenuItem*) + DoAppend__6wxMenuFP10wxMenuItem ;wxMenu::CopyAccels(wxAcceleratorEntry*) const CopyAccels__6wxMenuCFP18wxAcceleratorEntry ;wxMenuBar::Refresh() @@ -14977,8 +14987,8 @@ EXPORTS FindItemByHWND__8wxWindowCFUlT1 ;wxWindow::HandleKeyUp(void*,void*) HandleKeyUp__8wxWindowFPvT1 - ;wxWindow::HandleChar(unsigned long,void*,unsigned long) - HandleChar__8wxWindowFUlPvT1 + ;wxWindow::HandleChar(void*,void*,unsigned long) + HandleChar__8wxWindowFPvT1Ul ;wxWindow::DoMoveWindow(int,int,int,int) DoMoveWindow__8wxWindowFiN31 ;wxWindow::DoClientToScreen(int*,int*) const -- 2.45.2