From ad9bb75ff2c6a1734c24742c5f39ed8be197e16d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 26 Oct 1999 23:38:33 +0000 Subject: [PATCH] 1. regenerated the makefiles to include menucmn.cpp 2. more compilation fixes for DW changes 3. implemented dynamic menu support for wxMSW 4. added code to the toolbar sample to test it git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4206 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/menu.h | 7 - samples/toolbar/test.cpp | 303 ++++++++++++++++++++++++++++++--------- samples/toolbar/test.h | 62 -------- src/msw/makefile.b32 | 5 +- src/msw/makefile.bcc | 5 +- src/msw/makefile.dos | 8 +- src/msw/makefile.g95 | 3 +- src/msw/makefile.sc | 3 +- src/msw/makefile.vc | 3 +- src/msw/makefile.wat | 6 +- src/msw/menu.cpp | 192 +++++++++++-------------- src/msw/ole/droptgt.cpp | 5 +- 12 files changed, 348 insertions(+), 254 deletions(-) delete mode 100644 samples/toolbar/test.h diff --git a/include/wx/msw/menu.h b/include/wx/msw/menu.h index 4c4ecc8640..84746929c6 100644 --- a/include/wx/msw/menu.h +++ b/include/wx/msw/menu.h @@ -128,7 +128,6 @@ public: bool ProcessCommand(wxCommandEvent& event); - virtual void SetParent(wxEvtHandler *parent) { m_parent = parent; } void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; } wxEvtHandler *GetEventHandler() const { return m_eventHandler; } @@ -182,7 +181,6 @@ private: wxMenu * m_topLevelMenu; wxMenuBar * m_menuBar; wxList m_menuItems; - wxEvtHandler * m_parent; wxEvtHandler * m_eventHandler; wxWindow *m_pInvokingWindow; void* m_clientData; @@ -223,11 +221,6 @@ public: virtual void SetLabelTop( size_t pos, const wxString& label ); virtual wxString GetLabelTop( size_t pos ) const; - // notifications: return FALSE to prevent the menu from being - // appended/deleted - virtual bool OnAppend(wxMenu *menu, const wxChar *title); - virtual bool OnDelete(wxMenu *menu, int index); - // compatibility: these functions are deprecated #ifdef WXWIN_COMPATIBILITY void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; } diff --git a/samples/toolbar/test.cpp b/samples/toolbar/test.cpp index cc2111486b..2c35512d9d 100644 --- a/samples/toolbar/test.cpp +++ b/samples/toolbar/test.cpp @@ -6,86 +6,166 @@ // Created: 04/01/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// +// ============================================================================ +// declarations +// ============================================================================ + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + // For compilers that support precompilation, includes "wx/wx.h". -#include "wx/wxprec.h" +#include #ifdef __BORLANDC__ -#pragma hdrstop + #pragma hdrstop #endif #ifndef WX_PRECOMP -#include "wx/wx.h" + #include #endif -#include "wx/toolbar.h" +#include #include -#include "test.h" +// ---------------------------------------------------------------------------- +// resources +// ---------------------------------------------------------------------------- #if defined(__WXGTK__) || defined(__WXMOTIF__) -#include "mondrian.xpm" -#include "bitmaps/new.xpm" -#include "bitmaps/open.xpm" -#include "bitmaps/save.xpm" -#include "bitmaps/copy.xpm" -#include "bitmaps/cut.xpm" -// #include "bitmaps/paste.xpm" -#include "bitmaps/print.xpm" -#include "bitmaps/preview.xpm" -#include "bitmaps/help.xpm" -#endif + #include "mondrian.xpm" + #include "bitmaps/new.xpm" + #include "bitmaps/open.xpm" + #include "bitmaps/save.xpm" + #include "bitmaps/copy.xpm" + #include "bitmaps/cut.xpm" + // #include "bitmaps/paste.xpm" + #include "bitmaps/print.xpm" + #include "bitmaps/preview.xpm" + #include "bitmaps/help.xpm" +#endif // GTK or Motif + +// ---------------------------------------------------------------------------- +// classes +// ---------------------------------------------------------------------------- + +// Define a new application +class MyApp: public wxApp +{ +public: + bool OnInit(); + bool InitToolbar(wxToolBar* toolBar, bool smallicons = FALSE); +}; -IMPLEMENT_APP(MyApp) +// Define a new frame +class MyFrame: public wxFrame +{ +public: + MyFrame(wxFrame *parent, + wxWindowID id = -1, + const wxString& title = "wxToolBar Sample", + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME_STYLE); -// The `main program' equivalent, creating the windows and returning the -// main frame -bool MyApp::OnInit() + virtual ~MyFrame() { delete m_menu; } + + void OnQuit(wxCommandEvent& event); + void OnAbout(wxCommandEvent& event); + + void OnToggleToolbar(wxCommandEvent& event); + void OnEnablePrint(wxCommandEvent& event) { DoEnablePrint(); } + void OnToggleHelp(wxCommandEvent& event) { DoToggleHelp(); } + + void OnAppendMenu(wxCommandEvent& event); + void OnDeleteMenu(wxCommandEvent& event); + void OnToggleMenu(wxCommandEvent& event); + + void OnToolLeftClick(wxCommandEvent& event); + void OnToolEnter(wxCommandEvent& event); + +private: + void DoEnablePrint(); + void DoToggleHelp(); + + bool m_smallToolbar; + wxTextCtrl* m_textWindow; + + wxMenu *m_menu; + + DECLARE_EVENT_TABLE() +}; + +// ---------------------------------------------------------------------------- +// constants +// ---------------------------------------------------------------------------- + +const int ID_TOOLBAR = 500; + +enum { - // Create the main frame window - MyFrame* frame = new MyFrame((wxFrame *) NULL, -1, (const wxString) "wxToolBar Sample", - wxPoint(100, 100), wxSize(450, 300)); + IDM_TOOLBAR_TOGGLETOOLBAR = 200, + IDM_TOOLBAR_ENABLEPRINT, + IDM_TOOLBAR_TOGGLEHELP, + IDM_MENU_TOGGLE, + IDM_MENU_APPEND, + IDM_MENU_DELETE +}; - // Give it a status line - frame->CreateStatusBar(); +// ---------------------------------------------------------------------------- +// event tables +// ---------------------------------------------------------------------------- - // Give it an icon - frame->SetIcon(wxICON(mondrian)); +// Notice that wxID_HELP will be processed for the 'About' menu and the toolbar +// help button. - // Make a menubar - wxMenu *tbarMenu = new wxMenu; - tbarMenu->Append(IDM_TOOLBAR_TOGGLETOOLBAR, "&Toggle toolbar", "Change the toolbar kind"); - tbarMenu->Append(IDM_TOOLBAR_ENABLEPRINT, "&Enable print button", ""); - tbarMenu->Append(IDM_TOOLBAR_TOGGLEHELP, "Toggle &help button", ""); +BEGIN_EVENT_TABLE(MyFrame, wxFrame) + EVT_MENU(wxID_EXIT, MyFrame::OnQuit) + EVT_MENU(wxID_HELP, MyFrame::OnAbout) - wxMenu *fileMenu = new wxMenu; - fileMenu->Append(wxID_EXIT, "E&xit", "Quit toolbar sample" ); + EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBAR, MyFrame::OnToggleToolbar) + EVT_MENU(IDM_TOOLBAR_ENABLEPRINT, MyFrame::OnEnablePrint) + EVT_MENU(IDM_TOOLBAR_TOGGLEHELP, MyFrame::OnToggleHelp) - wxMenu *helpMenu = new wxMenu; - helpMenu->Append(wxID_HELP, "&About", "About toolbar sample"); + EVT_MENU(IDM_MENU_TOGGLE, MyFrame::OnToggleMenu) + EVT_MENU(IDM_MENU_APPEND, MyFrame::OnAppendMenu) + EVT_MENU(IDM_MENU_DELETE, MyFrame::OnDeleteMenu) - wxMenuBar* menuBar = new wxMenuBar( wxMB_DOCKABLE ); + EVT_MENU(-1, MyFrame::OnToolLeftClick) - menuBar->Append(fileMenu, "&File"); - menuBar->Append(tbarMenu, "&Toolbar"); - menuBar->Append(helpMenu, "&Help"); + EVT_TOOL_ENTER(ID_TOOLBAR, MyFrame::OnToolEnter) +END_EVENT_TABLE() - // Associate the menu bar with the frame - frame->SetMenuBar(menuBar); +// ============================================================================ +// implementation +// ============================================================================ - // Create the toolbar - frame->CreateToolBar(wxNO_BORDER|wxTB_HORIZONTAL|wxTB_FLAT|wxTB_DOCKABLE, ID_TOOLBAR); +// ---------------------------------------------------------------------------- +// MyApp +// ---------------------------------------------------------------------------- - frame->GetToolBar()->SetMargins( 2, 2 ); +IMPLEMENT_APP(MyApp) - InitToolbar(frame->GetToolBar()); +// The `main program' equivalent, creating the windows and returning the +// main frame +bool MyApp::OnInit() +{ + // Create the main frame window + MyFrame* frame = new MyFrame((wxFrame *) NULL, -1, + "wxToolBar Sample", + wxPoint(100, 100), wxSize(450, 300)); + // VZ: what's this for?? +#if 0 // Force a resize. This should probably be replaced by a call to a wxFrame // function that lays out default decorations and the remaining content window. wxSizeEvent event(wxSize(-1, -1), frame->GetId()); frame->OnSize(event); +#endif // 0 + frame->Show(TRUE); frame->SetStatusText("Hello, wxWindows"); @@ -154,7 +234,7 @@ bool MyApp::InitToolbar(wxToolBar* toolBar, bool smallicons) currentX += width + 5; toolBar->AddSeparator(); toolBar->AddTool(wxID_HELP, *(toolBarBitmaps[7]), *(toolBarBitmaps[6]), TRUE, currentX, -1, (wxObject *) NULL, "Help"); - + toolBar->EnableTool( wxID_PRINT, FALSE ); } @@ -168,19 +248,9 @@ bool MyApp::InitToolbar(wxToolBar* toolBar, bool smallicons) return TRUE; } -// wxID_HELP will be processed for the 'About' menu and the toolbar help button. - -BEGIN_EVENT_TABLE(MyFrame, wxFrame) - EVT_MENU(wxID_EXIT, MyFrame::OnQuit) - EVT_MENU(wxID_HELP, MyFrame::OnAbout) - - EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBAR, MyFrame::OnToggleToolbar) - EVT_MENU(IDM_TOOLBAR_ENABLEPRINT, MyFrame::OnEnablePrint) - EVT_MENU(IDM_TOOLBAR_TOGGLEHELP, MyFrame::OnToggleHelp) - - EVT_MENU(-1, MyFrame::OnToolLeftClick) - EVT_TOOL_ENTER(ID_TOOLBAR, MyFrame::OnToolEnter) -END_EVENT_TABLE() +// ---------------------------------------------------------------------------- +// MyFrame +// ---------------------------------------------------------------------------- // Define my frame constructor MyFrame::MyFrame(wxFrame* parent, @@ -191,18 +261,66 @@ MyFrame::MyFrame(wxFrame* parent, long style) : wxFrame(parent, id, title, pos, size, style) { + m_menu = NULL; m_textWindow = new wxTextCtrl(this, -1, "", wxPoint(0, 0), wxSize(-1, -1), wxTE_MULTILINE); m_smallToolbar = FALSE; + + // Give it a status line + CreateStatusBar(); + + // Give it an icon + SetIcon(wxICON(mondrian)); + + // Make a menubar + wxMenu *tbarMenu = new wxMenu; + tbarMenu->Append(IDM_TOOLBAR_TOGGLETOOLBAR, "&Toggle toolbar", "Change the toolbar kind"); + tbarMenu->Append(IDM_TOOLBAR_ENABLEPRINT, "&Enable print button", ""); + tbarMenu->Append(IDM_TOOLBAR_TOGGLEHELP, "Toggle &help button", ""); + + wxMenu *fileMenu = new wxMenu; + fileMenu->Append(wxID_EXIT, "E&xit", "Quit toolbar sample" ); + + wxMenu *menuMenu = new wxMenu; + menuMenu->Append(IDM_MENU_APPEND, "&Append menu"); + menuMenu->Append(IDM_MENU_DELETE, "&Delete menu"); + menuMenu->Append(IDM_MENU_TOGGLE, "&Toggle menu", "", TRUE); + + wxMenu *helpMenu = new wxMenu; + helpMenu->Append(wxID_HELP, "&About", "About toolbar sample"); + + wxMenuBar* menuBar = new wxMenuBar( wxMB_DOCKABLE ); + + menuBar->Append(fileMenu, "&File"); + menuBar->Append(tbarMenu, "&Toolbar"); + menuBar->Append(menuMenu, "&Menubar"); + menuBar->Append(helpMenu, "&Help"); + + // Associate the menu bar with the frame + SetMenuBar(menuBar); + + // Create the toolbar + wxToolBar *tbar = CreateToolBar(wxNO_BORDER | wxTB_HORIZONTAL | + wxTB_FLAT | wxTB_DOCKABLE, + ID_TOOLBAR); + + tbar->SetMargins( 2, 2 ); + + wxGetApp().InitToolbar(tbar); } -void MyFrame::OnToggleToolbar(wxCommandEvent& event) +void MyFrame::OnToggleToolbar(wxCommandEvent& WXUNUSED(event)) { - delete GetToolBar(); + // delete and recreate the toolbar + wxToolBar *tbar = GetToolBar(); + delete tbar; + SetToolBar(NULL); - CreateToolBar(wxNO_BORDER|wxTB_HORIZONTAL|wxTB_FLAT|wxTB_DOCKABLE, ID_TOOLBAR); + tbar = CreateToolBar(wxNO_BORDER | wxTB_HORIZONTAL | + wxTB_FLAT | wxTB_DOCKABLE, + ID_TOOLBAR); m_smallToolbar = !m_smallToolbar; - wxGetApp().InitToolbar(GetToolBar(), m_smallToolbar); + wxGetApp().InitToolbar(tbar, m_smallToolbar); } void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) @@ -215,25 +333,72 @@ void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) (void)wxMessageBox("wxWindows toolbar sample", "About wxToolBar"); } +void MyFrame::OnDeleteMenu(wxCommandEvent& WXUNUSED(event)) +{ + wxMenuBar *mbar = GetMenuBar(); + + size_t count = mbar->GetMenuCount(); + if ( count == 3 ) + { + // don't let delete the first 3 menus + wxLogError("Can't delete any more menus"); + } + else + { + delete mbar->Remove(count - 1); + } +} + +void MyFrame::OnAppendMenu(wxCommandEvent& WXUNUSED(event)) +{ + static s_count = 0; + + wxMenu *menu = new wxMenu; + menu->Append(0, "First item"); + menu->AppendSeparator(); + menu->Append(0, "Second item"); + + wxString title; + title.Printf("Dummy menu &%d", ++s_count); + + GetMenuBar()->Append(menu, title); +} + +void MyFrame::OnToggleMenu(wxCommandEvent& WXUNUSED(event)) +{ + wxMenuBar *mbar = GetMenuBar(); + if ( !m_menu ) + { + // hide the menu + m_menu = mbar->Remove(1); + } + else + { + // restore it + mbar->Insert(1, m_menu, "&Toolbar"); + m_menu = NULL; + } +} + void MyFrame::OnToolLeftClick(wxCommandEvent& event) { wxString str; str.Printf( _T("Clicked on tool %d\n"), event.GetId()); m_textWindow->WriteText( str ); - + if (event.GetId() == wxID_HELP) { - if ((bool)event.GetExtraLong()) + if ( event.GetExtraLong() != 0 ) m_textWindow->WriteText( _T("Help button down now.\n") ); else m_textWindow->WriteText( _T("Help button up now.\n") ); } - + if (event.GetId() == wxID_COPY) { DoEnablePrint(); } - + if (event.GetId() == wxID_CUT) { DoToggleHelp(); diff --git a/samples/toolbar/test.h b/samples/toolbar/test.h deleted file mode 100644 index 82f8950011..0000000000 --- a/samples/toolbar/test.h +++ /dev/null @@ -1,62 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: test.h -// Purpose: wxToolBar sample -// Author: Julian Smart -// Modified by: -// Created: 23/07/98 -// RCS-ID: $Id$ -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// Define a new application -class MyApp: public wxApp -{ -public: - bool OnInit(); - bool InitToolbar(wxToolBar* toolBar, bool smallicons = FALSE); -}; - -// Define a new frame -class MyFrame: public wxFrame -{ -public: - MyFrame(wxFrame *parent, - wxWindowID id = -1, - const wxString& title = "wxToolBar Sample", - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE); - - void OnQuit(wxCommandEvent& event); - void OnAbout(wxCommandEvent& event); - - void OnToggleToolbar(wxCommandEvent& event); - void OnEnablePrint(wxCommandEvent& event) { DoEnablePrint(); } - void OnToggleHelp(wxCommandEvent& event) { DoToggleHelp(); } - - void OnToolLeftClick(wxCommandEvent& event); - void OnToolEnter(wxCommandEvent& event); - -private: - void DoEnablePrint(); - void DoToggleHelp(); - - bool m_smallToolbar; - wxTextCtrl* m_textWindow; - - DECLARE_EVENT_TABLE() -}; - -// ---------------------------------------------------------------------------- -// constants -// ---------------------------------------------------------------------------- - -const int ID_TOOLBAR = 500; - -enum -{ - IDM_TOOLBAR_TOGGLETOOLBAR = 200, - IDM_TOOLBAR_ENABLEPRINT, - IDM_TOOLBAR_TOGGLEHELP -}; diff --git a/src/msw/makefile.b32 b/src/msw/makefile.b32 index 4ac339d40b..797fef6128 100644 --- a/src/msw/makefile.b32 +++ b/src/msw/makefile.b32 @@ -1,6 +1,6 @@ -# This file was automatically generated by tmake at 14:33, 1999/10/23 +# This file was automatically generated by tmake at 01:16, 1999/10/27 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE B32.T! # @@ -159,6 +159,7 @@ COMMONOBJS = \ $(MSWDIR)\list.obj \ $(MSWDIR)\log.obj \ $(MSWDIR)\memory.obj \ + $(MSWDIR)\menucmn.obj \ $(MSWDIR)\mimetype.obj \ $(MSWDIR)\module.obj \ $(MSWDIR)\mstream.obj \ @@ -630,6 +631,8 @@ $(MSWDIR)\log.obj: $(COMMDIR)\log.$(SRCSUFF) $(MSWDIR)\memory.obj: $(COMMDIR)\memory.$(SRCSUFF) +$(MSWDIR)\menucmn.obj: $(COMMDIR)\menucmn.$(SRCSUFF) + $(MSWDIR)\mimetype.obj: $(COMMDIR)\mimetype.$(SRCSUFF) $(MSWDIR)\module.obj: $(COMMDIR)\module.$(SRCSUFF) diff --git a/src/msw/makefile.bcc b/src/msw/makefile.bcc index e36dc50848..061cc490ee 100644 --- a/src/msw/makefile.bcc +++ b/src/msw/makefile.bcc @@ -1,6 +1,6 @@ -# This file was automatically generated by tmake at 09:40, 1999/10/25 +# This file was automatically generated by tmake at 01:16, 1999/10/27 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE BCC.T! # @@ -144,6 +144,7 @@ COMMONOBJS = \ $(MSWDIR)\list.obj \ $(MSWDIR)\log.obj \ $(MSWDIR)\memory.obj \ + $(MSWDIR)\menucmn.obj \ $(MSWDIR)\module.obj \ $(MSWDIR)\mstream.obj \ $(MSWDIR)\object.obj \ @@ -529,6 +530,8 @@ $(MSWDIR)\log.obj: $(COMMDIR)\log.$(SRCSUFF) $(MSWDIR)\memory.obj: $(COMMDIR)\memory.$(SRCSUFF) +$(MSWDIR)\menucmn.obj: $(COMMDIR)\menucmn.$(SRCSUFF) + $(MSWDIR)\module.obj: $(COMMDIR)\module.$(SRCSUFF) $(MSWDIR)\mstream.obj: $(COMMDIR)\mstream.$(SRCSUFF) diff --git a/src/msw/makefile.dos b/src/msw/makefile.dos index 56ced70de9..76f0e9c83c 100644 --- a/src/msw/makefile.dos +++ b/src/msw/makefile.dos @@ -1,4 +1,4 @@ -# This file was automatically generated by tmake at 09:37, 1999/10/25 +# This file was automatically generated by tmake at 01:16, 1999/10/27 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE DOS.T! # @@ -129,6 +129,7 @@ COMMONOBJS = \ $(COMMDIR)\list.obj \ $(COMMDIR)\log.obj \ $(COMMDIR)\memory.obj \ + $(COMMDIR)\menucmn.obj \ $(COMMDIR)\module.obj \ $(COMMDIR)\mstream.obj \ $(COMMDIR)\object.obj \ @@ -901,6 +902,11 @@ $(COMMDIR)/memory.obj: $*.$(SRCSUFF) $(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF) << +$(COMMDIR)/menucmn.obj: $*.$(SRCSUFF) + cl @<< +$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF) +<< + $(COMMDIR)/module.obj: $*.$(SRCSUFF) cl @<< $(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF) diff --git a/src/msw/makefile.g95 b/src/msw/makefile.g95 index 932f95baa3..ed9fbf62a7 100644 --- a/src/msw/makefile.g95 +++ b/src/msw/makefile.g95 @@ -1,4 +1,4 @@ -# This file was automatically generated by tmake at 18:37, 1999/10/22 +# This file was automatically generated by tmake at 01:16, 1999/10/27 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE G95.T! # @@ -109,6 +109,7 @@ COMMONOBJS = \ $(COMMDIR)/list.$(OBJSUFF) \ $(COMMDIR)/log.$(OBJSUFF) \ $(COMMDIR)/memory.$(OBJSUFF) \ + $(COMMDIR)/menucmn.$(OBJSUFF) \ $(COMMDIR)/mimetype.$(OBJSUFF) \ $(COMMDIR)/module.$(OBJSUFF) \ $(COMMDIR)/mstream.$(OBJSUFF) \ diff --git a/src/msw/makefile.sc b/src/msw/makefile.sc index cd285f4501..1ba33b4343 100644 --- a/src/msw/makefile.sc +++ b/src/msw/makefile.sc @@ -1,6 +1,6 @@ -# This file was automatically generated by tmake at 09:21, 1999/10/25 +# This file was automatically generated by tmake at 01:16, 1999/10/27 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE SC.T! # Symantec C++ makefile for the msw objects @@ -98,6 +98,7 @@ COMMONOBJS = \ $(COMMDIR)\list.obj \ $(COMMDIR)\log.obj \ $(COMMDIR)\memory.obj \ + $(COMMDIR)\menucmn.obj \ $(COMMDIR)\mimetype.obj \ $(COMMDIR)\module.obj \ $(COMMDIR)\mstream.obj \ diff --git a/src/msw/makefile.vc b/src/msw/makefile.vc index 7d9ab75738..1e3bd1a314 100644 --- a/src/msw/makefile.vc +++ b/src/msw/makefile.vc @@ -1,4 +1,4 @@ -# This file was automatically generated by tmake at 18:37, 1999/10/22 +# This file was automatically generated by tmake at 01:16, 1999/10/27 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE VC.T! # File: makefile.vc @@ -176,6 +176,7 @@ COMMONOBJS = \ ..\common\$D\list.obj \ ..\common\$D\log.obj \ ..\common\$D\memory.obj \ + ..\common\$D\menucmn.obj \ ..\common\$D\mimetype.obj \ ..\common\$D\module.obj \ ..\common\$D\mstream.obj \ diff --git a/src/msw/makefile.wat b/src/msw/makefile.wat index c04f50d4be..5f6a435ce2 100644 --- a/src/msw/makefile.wat +++ b/src/msw/makefile.wat @@ -1,6 +1,6 @@ #!/binb/wmake.exe -# This file was automatically generated by tmake at 09:14, 1999/10/25 +# This file was automatically generated by tmake at 01:16, 1999/10/27 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE WAT.T! # @@ -131,6 +131,7 @@ COMMONOBJS = & list.obj & log.obj & memory.obj & + menucmn.obj & mimetype.obj & module.obj & mstream.obj & @@ -716,6 +717,9 @@ log.obj: $(COMMDIR)\log.cpp memory.obj: $(COMMDIR)\memory.cpp *$(CCC) $(CPPFLAGS) $(IFLAGS) $< +menucmn.obj: $(COMMDIR)\menucmn.cpp + *$(CCC) $(CPPFLAGS) $(IFLAGS) $< + mimetype.obj: $(COMMDIR)\mimetype.cpp *$(CCC) $(CPPFLAGS) $(IFLAGS) $< diff --git a/src/msw/menu.cpp b/src/msw/menu.cpp index 46437db55e..1fb674564e 100644 --- a/src/msw/menu.cpp +++ b/src/msw/menu.cpp @@ -81,21 +81,20 @@ static const int idMenuTitle = -2; void wxMenu::Init(const wxString& title, const wxFunction func ) { m_title = title; - m_parent = NULL; m_eventHandler = this; m_pInvokingWindow = NULL; - m_doBreak = FALSE ; + m_doBreak = FALSE; m_noItems = 0; m_menuBar = NULL; m_hMenu = (WXHMENU) CreatePopupMenu(); - m_savehMenu = 0 ; + m_savehMenu = 0; m_topLevelMenu = this; m_clientData = (void*) NULL; if ( !!m_title ) { - Append(idMenuTitle, m_title) ; - AppendSeparator() ; + Append(idMenuTitle, m_title); + AppendSeparator(); } Callback(func); @@ -107,8 +106,10 @@ wxMenu::~wxMenu() // free Windows resources if ( m_hMenu ) { - ::DestroyMenu((HMENU)m_hMenu); - m_hMenu = 0; + if ( !::DestroyMenu(GetHmenu()) ) + { + wxLogLastError("DestroyMenu"); + } } // delete submenus @@ -128,6 +129,11 @@ wxMenu::~wxMenu() delete node; node = next; } + +#if wxUSE_ACCEL + // delete accels + WX_CLEAR_ARRAY(m_accels); +#endif // wxUSE_ACCEL } void wxMenu::Break() @@ -169,7 +175,6 @@ void wxMenu::Append(wxMenuItem *pItem) id = (UINT)submenu->GetHMenu(); submenu->m_topLevelMenu = m_topLevelMenu; - submenu->m_parent = this; submenu->m_savehMenu = (WXHMENU)id; submenu->m_hMenu = 0; @@ -269,7 +274,6 @@ void wxMenu::Delete(int id) RemoveMenu(menu, (UINT)pos, MF_BYPOSITION); pSubMenu->m_hMenu = pSubMenu->m_savehMenu; pSubMenu->m_savehMenu = 0; - pSubMenu->m_parent = NULL; // RemoveChild(item->subMenu); pSubMenu->m_topLevelMenu = NULL; // TODO: Why isn't subMenu deleted here??? @@ -344,7 +348,7 @@ bool wxMenu::IsChecked(int id) const void wxMenu::SetLabel(int id, const wxString& label) { - wxMenuItem *item = FindItemForId(id) ; + wxMenuItem *item = FindItemForId(id); wxCHECK_RET( item, wxT("wxMenu::SetLabel: no such item") ); item->SetText(label); @@ -353,9 +357,9 @@ void wxMenu::SetLabel(int id, const wxString& label) wxString wxMenu::GetLabel(int id) const { wxString label; - wxMenuItem *pItem = FindItemForId(id) ; + wxMenuItem *pItem = FindItemForId(id); if (pItem) - label = pItem->GetText() ; + label = pItem->GetText(); else wxFAIL_MSG(wxT("wxMenu::GetLabel: item doesn't exist")); @@ -574,6 +578,7 @@ void wxMenu::Detach() { wxASSERT_MSG( m_menuBar, wxT("can't detach menu if it's not attached") ); + m_menuBar = NULL; m_hMenu = m_savehMenu; m_savehMenu = 0; } @@ -585,7 +590,6 @@ void wxMenu::Detach() void wxMenuBar::Init() { m_eventHandler = this; - m_titles = NULL; m_menuBarFrame = NULL; m_hMenu = 0; } @@ -625,9 +629,9 @@ wxMenuBar::~wxMenuBar() void wxMenuBar::Refresh() { - wxCHECK_RET( m_menuBarFrame, wxT("can't refresh a menubar withotu a frame") ); + wxCHECK_RET( IsAttached(), wxT("can't refresh unatteched menubar") ); - DrawMenuBar((HWND)m_menuBarFrame->GetHWND()) ; + DrawMenuBar(GetHwndOf(m_menuBarFrame)); } WXHMENU wxMenuBar::Create() @@ -690,8 +694,8 @@ void wxMenuBar::SetLabelTop(size_t pos, const wxString& label) if ( flagsOld & MF_POPUP ) { // HIBYTE contains the number of items in the submenu in this case - flagsOld &= 0xff ; - id = (UINT)::GetSubMenu((HMENU)m_hMenu, pos) ; + flagsOld &= 0xff; + id = (UINT)::GetSubMenu((HMENU)m_hMenu, pos); } else { @@ -717,61 +721,6 @@ wxString wxMenuBar::GetLabelTop(size_t pos) const return label; } -// --------------------------------------------------------------------------- -// wxMenuBar notifications -// --------------------------------------------------------------------------- - -bool wxMenuBar::OnDelete(wxMenu *a_menu, int pos) -{ - if ( !m_menuBarFrame ) - return TRUE; - - if ( ::RemoveMenu((HMENU)m_hMenu, (UINT)pos, MF_BYPOSITION) ) - { - // VZ: I'm not sure about what's going on here, so I leave an assert - wxASSERT_MSG( m_menus[pos] == a_menu, wxT("what is this parameter for??") ); - - a_menu->Detach(); - - if ( m_menuBarFrame ) - Refresh(); - - return TRUE; - } - else - { - wxLogLastError("RemoveMenu"); - } - - return FALSE; -} - -bool wxMenuBar::OnAppend(wxMenu *a_menu, const wxChar *title) -{ - WXHMENU submenu = a_menu->GetHMenu(); - if ( !submenu ) - return FALSE; - - if ( !m_menuBarFrame ) - return TRUE; - - a_menu->Attach(this); - - if ( !::AppendMenu(GetHmenu(), MF_POPUP | MF_STRING, - (UINT)submenu, title) ) - { - wxLogLastError(wxT("AppendMenu")); - } - - Refresh(); - - return TRUE; -} - -// --------------------------------------------------------------------------- -// wxMenuBar construction -// --------------------------------------------------------------------------- - int wxMenuBar::FindMenu(const wxString& title) { wxString menuTitle = wxStripMenuCodes(title); @@ -788,56 +737,83 @@ int wxMenuBar::FindMenu(const wxString& title) } +// --------------------------------------------------------------------------- +// wxMenuBar construction +// --------------------------------------------------------------------------- + wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title) { - if ( m_menuBarFrame ) - { - wxFAIL_MSG(wxT("not implemented")); + wxMenu *menuOld = wxMenuBarBase::Replace(pos, menu, title); + if ( !menuOld ) + return FALSE; + m_titles[pos] = title; - return NULL; - } - else + if ( IsAttached() ) { - wxMenu *menuOld = wxMenuBarBase::Replace(pos, menu, title); - if ( menuOld ) + // can't use ModifyMenu() because it deletes the submenu it replaces + if ( !::RemoveMenu(GetHmenu(), (UINT)pos, MF_BYPOSITION) ) { - m_titles[pos] = title; + wxLogLastError("RemoveMenu"); } - return menuOld; + if ( !::InsertMenu(GetHmenu(), (UINT)pos, + MF_BYPOSITION | MF_POPUP | MF_STRING, + (UINT)GetHmenuOf(menu), title) ) + { + wxLogLastError("InsertMenu"); + } + + Refresh(); } + + return menuOld; } bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title) { - if ( m_menuBarFrame ) - { - wxFAIL_MSG(wxT("not implemented")); - + if ( !wxMenuBarBase::Insert(pos, menu, title) ) return FALSE; - } - else - { - if ( !wxMenuBarBase::Insert(pos, menu, title) ) - return FALSE; - m_titles.Insert(title, pos); + m_titles.Insert(title, pos); + + menu->Attach(this); - return TRUE; + if ( IsAttached() ) + { + if ( !::InsertMenu(GetHmenu(), pos, + MF_BYPOSITION | MF_POPUP | MF_STRING, + (UINT)GetHmenuOf(menu), title) ) + { + wxLogLastError("InsertMenu"); + } + + Refresh(); } + + return TRUE; } -bool wxMenuBar::Append(wxMenu * menu, const wxString& title) +bool wxMenuBar::Append(wxMenu *menu, const wxString& title) { - if ( !wxMenuBarBase::Append(menu, title) ) - return FALSE; + WXHMENU submenu = menu ? menu->GetHMenu() : 0; + wxCHECK_MSG( submenu, FALSE, wxT("can't append invalid menu to menubar") ); - // menu is already appended, ignore errors - (void)OnAppend(menu, title); + menu->Attach(this); - m_titles.Add(title); + if ( IsAttached() ) + { + if ( !::AppendMenu(GetHmenu(), MF_POPUP | MF_STRING, + (UINT)submenu, title) ) + { + wxLogLastError(wxT("AppendMenu")); + } + + Refresh(); + } - menu->SetParent(this); + wxMenuBarBase::Append(menu, title); + + m_titles.Add(title); return TRUE; } @@ -848,11 +824,17 @@ wxMenu *wxMenuBar::Remove(size_t pos) if ( !menu ) return NULL; - menu->SetParent(NULL); + if ( IsAttached() ) + { + if ( !::RemoveMenu(GetHmenu(), (UINT)pos, MF_BYPOSITION) ) + { + wxLogLastError("RemoveMenu"); + } - // the menu is deleted from the list anyhow, so we have to ignore all - // possible errors here - (void)OnDelete(menu, pos); + menu->Detach(); + + Refresh(); + } m_titles.Remove(pos); @@ -861,7 +843,7 @@ wxMenu *wxMenuBar::Remove(size_t pos) void wxMenuBar::Attach(wxFrame *frame) { - wxASSERT_MSG( !m_menuBarFrame, wxT("menubar already attached!") ); + wxASSERT_MSG( !IsAttached(), wxT("menubar already attached!") ); m_menuBarFrame = frame; diff --git a/src/msw/ole/droptgt.cpp b/src/msw/ole/droptgt.cpp index 67825f8569..329716dd27 100644 --- a/src/msw/ole/droptgt.cpp +++ b/src/msw/ole/droptgt.cpp @@ -260,14 +260,11 @@ STDMETHODIMP wxIDropTarget::Drop(IDataObject *pIDataSource, // and now it has the data wxDragResult rc = ConvertDragEffectToResult(GetDropEffect(grfKeyState)); - m_pTarget->OnData(pt.x, pt.y);//, rc); -/* + m_pTarget->OnData(pt.x, pt.y, rc); if ( wxIsDragResultOk(rc) ) { // operation succeeded *pdwEffect = ConvertDragResultToEffect(rc); } -*/ - //else: *pdwEffect is already DROPEFFECT_NONE } //else: OnDrop() returned FALSE, no need to copy data -- 2.47.2