From: John L. <jr...@us...> - 2007-05-08 00:55:16
|
Update of /cvsroot/wxlua/wxLua/apps/wxluaedit/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv8721/wxLua/apps/wxluaedit/src Modified Files: wxledit.cpp wxledit.h Log Message: Add accelerators for running, breaking in wxLuaEdit Fix "reset" to work every time in the wxLuaShell Use simplified wxWidgets (>2.6?) macros for declaring the wxLuaEvents Index: wxledit.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/apps/wxluaedit/src/wxledit.h,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** wxledit.h 15 Dec 2006 19:04:48 -0000 1.17 --- wxledit.h 8 May 2007 00:55:12 -0000 1.18 *************** *** 69,78 **** BEGIN_DECLARE_EVENT_TYPES() ! DECLARE_LOCAL_EVENT_TYPE(wxEVT_LUASHELL_wxLUA_CREATION, 7000) ! DECLARE_LOCAL_EVENT_TYPE(wxEVT_LUAIDE_wxLUA_CREATION, 7001) END_DECLARE_EVENT_TYPES() ! #define EVT_LUASHELL_wxLUA_CREATION(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_LUASHELL_wxLUA_CREATION, id, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxNotifyEventFunction) (wxLuaEventFunction) & fn, (wxObject *) NULL ), ! #define EVT_LUAIDE_wxLUA_CREATION(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_LUAIDE_wxLUA_CREATION, id, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxNotifyEventFunction) (wxLuaEventFunction) & fn, (wxObject *) NULL ), //----------------------------------------------------------------------------- --- 69,78 ---- BEGIN_DECLARE_EVENT_TYPES() ! DECLARE_LOCAL_EVENT_TYPE(wxEVT_LUASHELL_wxLUA_CREATION, 7000) ! DECLARE_LOCAL_EVENT_TYPE(wxEVT_LUAIDE_wxLUA_CREATION, 7001) END_DECLARE_EVENT_TYPES() ! #define EVT_LUASHELL_wxLUA_CREATION(id, fn) wx__DECLARE_WXLUAEVT(wxEVT_LUASHELL_wxLUA_CREATION, id, fn) ! #define EVT_LUAIDE_wxLUA_CREATION(id, fn) wx__DECLARE_WXLUAEVT(wxEVT_LUAIDE_wxLUA_CREATION, id, fn) //----------------------------------------------------------------------------- *************** *** 120,130 **** // and event.SetInt(1 for static interpreter or 0 for not static), where // static means that the wxLuaShell will not close the wxLuaState on exit. ! // You'll probably want to set the new wxLuaState's eventhandler ! // to this as well as it's win id. // ! // If the event is skipped or not handled the RecreatewxLuaState will call ! // SetLuaIntpreter(event.GetLuaInterpreter(), event.GetInt() == 1) ! // if the event's wxLuaState is valid. You can not skip the event to not have ! // the wxLuaState recreated at all. virtual bool RecreatewxLuaState(wxEvtHandler *wxlStateEvtHandler, int win_id); --- 120,130 ---- // and event.SetInt(1 for static interpreter or 0 for not static), where // static means that the wxLuaShell will not close the wxLuaState on exit. ! // You'll probably want to set the new wxLuaState's eventhandler and id ! // to that of this window so this can handle the events. // ! // If the event is skipped or not handled the RecreatewxLuaState function ! // will call SetLuaIntpreter(event.GetLuaInterpreter(), event.GetInt() == 1) ! // if the event's wxLuaState is valid. You can Skip(false) the event to ! // not have the wxLuaState recreated at all. virtual bool RecreatewxLuaState(wxEvtHandler *wxlStateEvtHandler, int win_id); *************** *** 254,258 **** // Used to create/recreate local interpreter // Can be subclassed to use your own interpreter derived from a wxLuaState ! // or a new interpreter can be set in by catching the wxEVT_LUASHELL_wxLUA_CREATION // wxLuaEvent that's sent with this control's id and *this as the GetEventObject // the preferred window ID is in event.GetExtraLong() --- 254,258 ---- // Used to create/recreate local interpreter // Can be subclassed to use your own interpreter derived from a wxLuaState ! // or a new interpreter can be set by catching the EVT_LUAIDE_wxLUA_CREATION // wxLuaEvent that's sent with this control's id and *this as the GetEventObject // the preferred window ID is in event.GetExtraLong() Index: wxledit.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/apps/wxluaedit/src/wxledit.cpp,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** wxledit.cpp 15 Dec 2006 19:04:47 -0000 1.30 --- wxledit.cpp 8 May 2007 00:55:12 -0000 1.31 *************** *** 99,122 **** bool wxLuaShell::RecreatewxLuaState(wxEvtHandler *wxlStateEvtHandler, int win_id) { ! // ask if anyone else wants to create the wxLuaState for us wxLuaEvent event(wxEVT_LUASHELL_wxLUA_CREATION, GetId(), m_wxlState); ! event.SetEventObject(this); event.SetInt(0); event.SetExtraLong(win_id); // return if handled, but not skipped. if (GetEventHandler()->ProcessEvent(event)) return false; ! if (event.GetwxLuaState().Ok()) { SetwxLuaState(event.GetwxLuaState(), event.GetInt() == 1); ! return true; } ! wxLuaState wxlState = wxLuaState(wxlStateEvtHandler, win_id); ! wxlState.SetLuaDebugHook( 1000, 50, false, LUA_MASKCOUNT ); ! SetwxLuaState(wxlState, false); ! ! return true; } --- 99,128 ---- bool wxLuaShell::RecreatewxLuaState(wxEvtHandler *wxlStateEvtHandler, int win_id) { ! // ask if anyone else wants to create a new wxLuaState for us wxLuaEvent event(wxEVT_LUASHELL_wxLUA_CREATION, GetId(), m_wxlState); ! event.SetEventObject(this); event.SetInt(0); event.SetExtraLong(win_id); + // return if handled, but not skipped. if (GetEventHandler()->ProcessEvent(event)) return false; ! // Did they set a valid interpreter for the event and is it new? ! // If it's not different then assume they didn't change it so we'll create ! // a new one below. If they wanted to just adjust the current state they ! // should have called event.Skip(false) ! if (event.GetwxLuaState().Ok() && (event.GetwxLuaState() != m_wxlState)) { SetwxLuaState(event.GetwxLuaState(), event.GetInt() == 1); ! } ! else ! { ! wxLuaState wxlState = wxLuaState(wxlStateEvtHandler, win_id); ! wxlState.SetLuaDebugHook( 1000, 50, false, LUA_MASKCOUNT ); ! SetwxLuaState(wxlState, false); } ! return m_wxlState.Ok(); } *************** *** 392,395 **** --- 398,402 ---- m_editorOptions.GetEditorPopupMenu()->Append(wxID_ANY, wxT("wxLua"), wxluaMenu); + // ----------------------------------------------------------------------- // Create the message notebook for shell and output window m_shellOptions.SetSplitterOptions(STS_NO_EDITOR); *************** *** 403,409 **** --- 410,419 ---- m_msgNotebook->CreateOptions(m_shellOptions); + // ----------------------------------------------------------------------- + // Create the interactive lua shell wxSTEditorSplitter *steSplitter = new wxSTEditorSplitter(m_msgNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D); steSplitter->CreateOptions(m_shellOptions); + m_luaShell = new wxLuaShell(steSplitter, ID_WXLUAIDE_SHELL, wxDefaultPosition, wxDefaultSize, 0); *************** *** 415,418 **** --- 425,430 ---- m_msgNotebook->InsertEditorSplitter(-1, steSplitter, true); + // ----------------------------------------------------------------------- + // Create the interactive lua shell for the output of the editor programs steSplitter = new wxSTEditorSplitter(m_msgNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D); *************** *** 426,429 **** --- 438,443 ---- m_luaOutput->SetWrapMode(wxSTC_WRAP_NONE); m_luaOutput->SetFileName(wxT("Output")); + + m_msgNotebook->InsertEditorSplitter(-1, steSplitter, false); *************** *** 471,476 **** void wxLuaIDE::SetMenuBar(wxMenuBar *menuBar) { - m_editorOptions.SetMenuBar(menuBar); m_shellOptions.SetMenuBar(menuBar); if (menuBar && (menuBar->FindMenu(wxT("wxLua")) == wxNOT_FOUND)) { --- 485,491 ---- void wxLuaIDE::SetMenuBar(wxMenuBar *menuBar) { m_shellOptions.SetMenuBar(menuBar); + m_editorOptions.SetMenuBar(menuBar); + if (menuBar && (menuBar->FindMenu(wxT("wxLua")) == wxNOT_FOUND)) { *************** *** 486,491 **** void wxLuaIDE::SetToolBar(wxToolBar *toolBar) { - m_editorOptions.SetToolBar(toolBar); m_shellOptions.SetToolBar(toolBar); m_toolBar = toolBar; --- 501,506 ---- void wxLuaIDE::SetToolBar(wxToolBar *toolBar) { m_shellOptions.SetToolBar(toolBar); + m_editorOptions.SetToolBar(toolBar); m_toolBar = toolBar; *************** *** 509,513 **** if (add_sep) toolBar->AddSeparator(); ! toolBar->AddTool( ID_WXLUAIDE_RUN_LUA, wxT("Run wxLua program"), wxBitmap(play_xpm), wxT("Run the wxLua program") ); toolBar->AddTool( ID_WXLUAIDE_BREAK_LUA, wxT("Stop wxLua program"), wxBitmap(stop_xpm), wxT("Stop the running wxLua program") ); toolBar->AddSeparator(); --- 524,528 ---- if (add_sep) toolBar->AddSeparator(); ! toolBar->AddTool( ID_WXLUAIDE_RUN_LUA, wxT("Run wxLua program"), wxBitmap(play_xpm), wxT("Run the wxLua program in the current editor") ); toolBar->AddTool( ID_WXLUAIDE_BREAK_LUA, wxT("Stop wxLua program"), wxBitmap(stop_xpm), wxT("Stop the running wxLua program") ); toolBar->AddSeparator(); *************** *** 521,530 **** wxSTEditorMenuManager s; wxMenu *wxluaMenu = new wxMenu(); ! wxluaMenu->Append(s.MenuItem(wxluaMenu, ID_WXLUAIDE_RUN_LUA, wxT("&Run wxLua program"), wxT("Run the wxLua program") , wxITEM_NORMAL, wxBitmap(play_xpm))); ! wxluaMenu->Append(s.MenuItem(wxluaMenu, ID_WXLUAIDE_BREAK_LUA, wxT("&Stop wxLua program"), wxT("Stop the running wxLua program") , wxITEM_NORMAL, wxBitmap(stop_xpm))); wxluaMenu->AppendSeparator(); wxluaMenu->Append(s.MenuItem(wxluaMenu, ID_WXLUAIDE_SHOW_STACK, wxT("Stack &tree"), wxT("Show the lua stack tree") , wxITEM_NORMAL, wxBitmap(LUA_xpm))); wxluaMenu->AppendSeparator(); ! wxluaMenu->Append(ID_WXLUAIDE_TOGGLE_BREAKPOINT, wxT("&Toggle breakpoint")); return wxluaMenu; } --- 536,545 ---- wxSTEditorMenuManager s; wxMenu *wxluaMenu = new wxMenu(); ! wxluaMenu->Append(s.MenuItem(wxluaMenu, ID_WXLUAIDE_RUN_LUA, wxT("&Run wxLua program\tCtrl+F5"), wxT("Run the wxLua program in the current editor") , wxITEM_NORMAL, wxBitmap(play_xpm))); ! wxluaMenu->Append(s.MenuItem(wxluaMenu, ID_WXLUAIDE_BREAK_LUA, wxT("&Stop wxLua program\tShift+F5"), wxT("Stop the running wxLua program") , wxITEM_NORMAL, wxBitmap(stop_xpm))); wxluaMenu->AppendSeparator(); wxluaMenu->Append(s.MenuItem(wxluaMenu, ID_WXLUAIDE_SHOW_STACK, wxT("Stack &tree"), wxT("Show the lua stack tree") , wxITEM_NORMAL, wxBitmap(LUA_xpm))); wxluaMenu->AppendSeparator(); ! wxluaMenu->Append(ID_WXLUAIDE_TOGGLE_BREAKPOINT, wxT("Toggle &breakpoint")); return wxluaMenu; } *************** *** 550,569 **** bool wxLuaIDE::RecreatewxLuaState(wxEvtHandler *wxlStateEvtHandler, int win_id) { wxLuaEvent event(wxEVT_LUAIDE_wxLUA_CREATION, GetId(), wxNullLuaState); event.SetEventObject(this); event.SetInt(0); event.SetExtraLong(win_id); - GetEventHandler()->ProcessEvent( event ); if (event.GetwxLuaState().Ok()) { SetwxLuaState(event.GetwxLuaState(), event.GetInt() == 1); ! return true; } ! wxLuaState wxlState = wxLuaState(wxlStateEvtHandler, win_id); ! wxlState.SetLuaDebugHook( 1000, 50, false, LUA_MASKCOUNT ); ! SetwxLuaState(wxlState, false); ! return true; } --- 565,594 ---- bool wxLuaIDE::RecreatewxLuaState(wxEvtHandler *wxlStateEvtHandler, int win_id) { + // ask if anyone else wants to create a new wxLuaState for us wxLuaEvent event(wxEVT_LUAIDE_wxLUA_CREATION, GetId(), wxNullLuaState); event.SetEventObject(this); event.SetInt(0); event.SetExtraLong(win_id); + // return if handled, but not skipped. + if (GetEventHandler()->ProcessEvent(event)) + return false; + + // Did they set a valid interpreter for the event and is it new? + // If it's not different then assume they didn't change it so we'll create + // a new one below. If they wanted to just adjust the current state they + // should have called event.Skip(false) if (event.GetwxLuaState().Ok()) { SetwxLuaState(event.GetwxLuaState(), event.GetInt() == 1); ! } ! else ! { ! wxLuaState wxlState = wxLuaState(wxlStateEvtHandler, win_id); ! wxlState.SetLuaDebugHook( 1000, 50, false, LUA_MASKCOUNT ); ! SetwxLuaState(wxlState, false); } ! return m_wxlState.Ok(); } |