From: Markus R. <rol...@us...> - 2006-01-09 11:28:32
|
Update of /cvsroot/simspark/simspark/contrib/rsgedit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29981 Modified Files: Makefile.am main.cpp mainframe.cpp mainframe.h rsgedit.wxg simspark.cpp Log Message: - added compiles fixes from Joschka - added object hierarchy tree pane - added show/hide toggles for log and tree panes to menu Index: main.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/main.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** main.cpp 4 Jan 2006 20:31:58 -0000 1.4 --- main.cpp 9 Jan 2006 11:28:24 -0000 1.5 *************** *** 57,61 **** } ! mainframe* frame = new mainframe(NULL, wxID_ANY, "RsgEdit"); // Show the frame --- 57,61 ---- } ! mainframe* frame = new mainframe(NULL, wxID_ANY, _T("RsgEdit")); // Show the frame Index: mainframe.h =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/mainframe.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** mainframe.h 8 Jan 2006 15:37:36 -0000 1.4 --- mainframe.h 9 Jan 2006 11:28:24 -0000 1.5 *************** *** 21,24 **** --- 21,25 ---- #include <wx/wx.h> #include <wx/image.h> + #include "sparktree.h" #ifndef MAINFRAME_H *************** *** 29,36 **** // begin wxGlade: ::dependencies #include <wx/splitter.h> // end wxGlade ! #define ID_SIM_START (wxID_HIGHEST+1) ! #define ID_SIM_PAUSE (wxID_HIGHEST+2) class mainframe: public wxFrame { --- 30,42 ---- // begin wxGlade: ::dependencies #include <wx/splitter.h> + #include <wx/treectrl.h> // end wxGlade ! #define ID_SIM_START (wxID_HIGHEST+10) ! #define ID_SIM_PAUSE (wxID_HIGHEST+11) ! ! #define ID_VIEW_LOG (wxID_HIGHEST+20) ! #define ID_VIEW_TREE (wxID_HIGHEST+21) ! #define ID_VIEW_TOOLBAR (wxID_HIGHEST+22) class mainframe: public wxFrame { *************** *** 60,63 **** --- 66,75 ---- void OnPauseSimulation(wxCommandEvent& event); + void OnViewTree(wxCommandEvent& event); + void OnUpdateViewTree(wxUpdateUIEvent& event); + + void OnViewLog(wxCommandEvent& event); + void OnUpdateViewLog(wxUpdateUIEvent& event); + void OnExit(wxCommandEvent& event); void OnClose( wxCloseEvent& event ); *************** *** 71,82 **** bool CanClose(); protected: // begin wxGlade: mainframe::attributes wxMenuBar* MainFrame_menubar; wxStatusBar* MainFrame_statusbar; SparkGLCanvas* mCanvas; ! wxPanel* window_1_pane_1; wxTextCtrl* mCtrLog; ! wxPanel* window_1_pane_2; wxSplitterWindow* mCtrVertSplitter; // end wxGlade --- 83,105 ---- bool CanClose(); + void OnTreeItemExpanding(wxTreeEvent& event); + void OnTreeSelChanged(wxTreeEvent& event); + + void SplitHor(); + void SplitVert(); + protected: // begin wxGlade: mainframe::attributes wxMenuBar* MainFrame_menubar; wxStatusBar* MainFrame_statusbar; + wxTextCtrl* mCtrLocation; + wxTreeCtrl* mCtrTree; + wxPanel* mLeftPane; SparkGLCanvas* mCanvas; ! wxPanel* mTopPane; wxTextCtrl* mCtrLog; ! wxPanel* mBottomPane; ! wxSplitterWindow* mCtrHorSplitter; ! wxPanel* mRightPane; wxSplitterWindow* mCtrVertSplitter; // end wxGlade *************** *** 85,88 **** --- 108,115 ---- wxTimer mTimer; wxToolBar* mToolBar; + SparkTree mSparkTree; + + int mLastHorSashPosition; + int mLastVertSashPosition; DECLARE_EVENT_TABLE() Index: simspark.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/simspark.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** simspark.cpp 8 Jan 2006 15:37:37 -0000 1.3 --- simspark.cpp 9 Jan 2006 11:28:24 -0000 1.4 *************** *** 78,82 **** wxString SimSpark::GetLogBuffer() { ! return wxString(mLogStream.str().c_str()); } --- 78,82 ---- wxString SimSpark::GetLogBuffer() { ! return wxString(mLogStream.str().c_str(), wxConvUTF8); } Index: rsgedit.wxg =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/rsgedit.wxg,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** rsgedit.wxg 8 Jan 2006 15:37:37 -0000 1.2 --- rsgedit.wxg 9 Jan 2006 11:28:24 -0000 1.3 *************** *** 1,4 **** <?xml version="1.0"?> ! <!-- generated by wxGlade 0.4 on Sun Jan 8 16:37:09 2006 --> <application path="/home/markus/cvs/simspark/contrib/rsgedit" name="" class="" option="1" language="C++" top_window="MainFrame" encoding="UTF-8" use_gettext="0" overwrite="0" use_new_namespace="1" for_version="2.6"> --- 1,4 ---- <?xml version="1.0"?> ! <!-- generated by wxGlade 0.4 on Sun Jan 8 22:39:29 2006 --> <application path="/home/markus/cvs/simspark/contrib/rsgedit" name="" class="" option="1" language="C++" top_window="MainFrame" encoding="UTF-8" use_gettext="0" overwrite="0" use_new_namespace="1" for_version="2.6"> *************** *** 43,70 **** <option>1</option> <object class="wxSplitterWindow" name="mCtrVertSplitter" base="EditSplitterWindow"> ! <style>wxSP_3D|wxSP_BORDER|wxSP_LIVE_UPDATE</style> ! <orientation>wxSPLIT_HORIZONTAL</orientation> ! <window_2>window_1_pane_2</window_2> ! <window_1>window_1_pane_1</window_1> ! <object class="wxPanel" name="window_1_pane_1" base="EditPanel"> <style>wxTAB_TRAVERSAL</style> ! <object class="wxBoxSizer" name="sizer_3" base="EditBoxSizer"> ! <orient>wxHORIZONTAL</orient> <object class="sizeritem"> <flag>wxEXPAND</flag> <border>0</border> <option>1</option> ! <object class="SparkGLCanvas" name="mCanvas" base="CustomWidget"> ! <arguments> ! <argument>$parent</argument> ! <argument>$id</argument> ! </arguments> </object> </object> </object> </object> ! <object class="wxPanel" name="window_1_pane_2" base="EditPanel"> <style>wxTAB_TRAVERSAL</style> ! <object class="wxBoxSizer" name="sizer_4" base="EditBoxSizer"> <orient>wxVERTICAL</orient> <object class="sizeritem"> --- 43,68 ---- <option>1</option> <object class="wxSplitterWindow" name="mCtrVertSplitter" base="EditSplitterWindow"> ! <style>wxSP_3D|wxSP_BORDER</style> ! <orientation>wxSPLIT_VERTICAL</orientation> ! <window_2>rightPane</window_2> ! <window_1>leftPane</window_1> ! <object class="wxPanel" name="leftPane" base="EditPanel"> <style>wxTAB_TRAVERSAL</style> ! <object class="wxBoxSizer" name="sizer_7" base="EditBoxSizer"> ! <orient>wxVERTICAL</orient> <object class="sizeritem"> <flag>wxEXPAND</flag> <border>0</border> <option>1</option> ! <object class="wxTreeCtrl" name="mCtrTree" base="EditTreeCtrl"> ! <style>wxTR_HAS_BUTTONS|wxTR_NO_LINES|wxTR_DEFAULT_STYLE|wxSUNKEN_BORDER</style> ! <id>1</id> </object> </object> </object> </object> ! <object class="wxPanel" name="rightPane" base="EditPanel"> <style>wxTAB_TRAVERSAL</style> ! <object class="wxBoxSizer" name="sizer_2" base="EditBoxSizer"> <orient>wxVERTICAL</orient> <object class="sizeritem"> *************** *** 72,77 **** <border>0</border> <option>1</option> ! <object class="wxTextCtrl" name="mCtrLog" base="EditTextCtrl"> ! <style>wxTE_MULTILINE|wxTE_READONLY|wxHSCROLL|wxTE_LINEWRAP</style> </object> </object> --- 70,109 ---- <border>0</border> <option>1</option> ! <object class="wxSplitterWindow" name="mCtrHorSplitter" base="EditSplitterWindow"> ! <style>wxSP_3D|wxSP_BORDER</style> ! <orientation>wxSPLIT_HORIZONTAL</orientation> ! <window_2>bottomPane</window_2> ! <window_1>topPane</window_1> ! <object class="wxPanel" name="topPane" base="EditPanel"> ! <style>wxTAB_TRAVERSAL</style> ! <object class="wxBoxSizer" name="sizer_5" base="EditBoxSizer"> ! <orient>wxVERTICAL</orient> ! <object class="sizeritem"> ! <flag>wxEXPAND</flag> ! <border>0</border> ! <option>1</option> ! <object class="SparkGLCanvas" name="mCanvas" base="CustomWidget"> ! <arguments> ! <argument>$parent</argument> ! <argument>$id</argument> ! </arguments> ! </object> ! </object> ! </object> ! </object> ! <object class="wxPanel" name="bottomPane" base="EditPanel"> ! <style>wxTAB_TRAVERSAL</style> ! <object class="wxBoxSizer" name="sizer_6" base="EditBoxSizer"> ! <orient>wxVERTICAL</orient> ! <object class="sizeritem"> ! <flag>wxEXPAND</flag> ! <border>0</border> ! <option>1</option> ! <object class="wxTextCtrl" name="mCtrLog" base="EditTextCtrl"> ! <style>wxTE_MULTILINE|wxTE_READONLY|wxHSCROLL|wxTE_LINEWRAP</style> ! </object> ! </object> ! </object> ! </object> </object> </object> Index: Makefile.am =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/Makefile.am,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Makefile.am 2 Jan 2006 20:28:49 -0000 1.2 --- Makefile.am 9 Jan 2006 11:28:24 -0000 1.3 *************** *** 23,27 **** simspark.cpp\ sparkglrender.cpp\ ! inputwx.cpp --- 23,29 ---- simspark.cpp\ sparkglrender.cpp\ ! inputwx.cpp\ ! sparktree.cpp ! Index: mainframe.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/mainframe.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** mainframe.cpp 8 Jan 2006 15:37:36 -0000 1.5 --- mainframe.cpp 9 Jan 2006 11:28:24 -0000 1.6 *************** *** 45,49 **** --- 45,59 ---- EVT_MENU(ID_SIM_PAUSE, mainframe::OnPauseSimulation) + EVT_MENU(ID_VIEW_LOG, mainframe::OnViewLog) + EVT_UPDATE_UI(ID_VIEW_LOG, mainframe::OnUpdateViewLog) + + EVT_MENU(ID_VIEW_TREE, mainframe::OnViewTree) + EVT_UPDATE_UI(ID_VIEW_TREE, mainframe::OnUpdateViewTree) + EVT_TIMER(1, mainframe::OnLogTimer) + + EVT_TREE_ITEM_EXPANDING(1, mainframe::OnTreeItemExpanding) + EVT_TREE_SEL_CHANGED(1, mainframe::OnTreeSelChanged) + END_EVENT_TABLE() *************** *** 58,61 **** --- 68,74 ---- static const int LOGWND_UPDATE_INTERVAL = 100; + // the default width of the tree window pane [pixel] + static const int TREEWND_DEFAULT_WIDTH = 150; + mainframe::mainframe(wxWindow* parent, int id, const wxString& title, const wxPoint& pos, const wxSize& size, long style): wxFrame(parent, id, title, pos, size, wxDEFAULT_FRAME_STYLE), *************** *** 63,69 **** { // begin wxGlade: mainframe::mainframe ! mCtrVertSplitter = new wxSplitterWindow(this, -1, wxDefaultPosition, wxDefaultSize, wxSP_3D|wxSP_BORDER|wxSP_LIVE_UPDATE); ! window_1_pane_2 = new wxPanel(mCtrVertSplitter, -1); ! window_1_pane_1 = new wxPanel(mCtrVertSplitter, -1); MainFrame_menubar = new wxMenuBar(); SetMenuBar(MainFrame_menubar); --- 76,85 ---- { // begin wxGlade: mainframe::mainframe ! mCtrVertSplitter = new wxSplitterWindow(this, -1, wxDefaultPosition, wxDefaultSize, wxSP_3D|wxSP_BORDER); ! mRightPane = new wxPanel(mCtrVertSplitter, -1); ! mCtrHorSplitter = new wxSplitterWindow(mRightPane, -1, wxDefaultPosition, wxDefaultSize, wxSP_3D|wxSP_BORDER); ! mBottomPane = new wxPanel(mCtrHorSplitter, -1); ! mTopPane = new wxPanel(mCtrHorSplitter, -1); ! mLeftPane = new wxPanel(mCtrVertSplitter, -1); MainFrame_menubar = new wxMenuBar(); SetMenuBar(MainFrame_menubar); *************** *** 72,81 **** MainFrame_menubar->Append(wxglade_tmp_menu_1, wxT("&File")); wxMenu* wxglade_tmp_menu_2 = new wxMenu(); ! wxglade_tmp_menu_2->Append(ID_SIM_START, wxT("&Start"), wxT("Start simulation"), wxITEM_NORMAL); ! wxglade_tmp_menu_2->Append(ID_SIM_PAUSE, wxT("&Pause"), wxT("Pause Simulation"), wxITEM_NORMAL); ! MainFrame_menubar->Append(wxglade_tmp_menu_2, wxT("&Simulation")); MainFrame_statusbar = CreateStatusBar(1, 0); ! mCanvas = new SparkGLCanvas(window_1_pane_1, -1); ! mCtrLog = new wxTextCtrl(window_1_pane_2, -1, wxT(""), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY|wxHSCROLL|wxTE_LINEWRAP); set_properties(); --- 88,103 ---- MainFrame_menubar->Append(wxglade_tmp_menu_1, wxT("&File")); wxMenu* wxglade_tmp_menu_2 = new wxMenu(); ! wxglade_tmp_menu_2->Append(ID_VIEW_LOG, wxT("message &log"), wxT("Show/Hide message log"), wxITEM_CHECK); ! wxglade_tmp_menu_2->Append(ID_VIEW_TREE, wxT("object &tree"), wxT("Show/Hide object tree"), wxITEM_CHECK); ! MainFrame_menubar->Append(wxglade_tmp_menu_2, wxT("&View")); ! wxMenu* wxglade_tmp_menu_3 = new wxMenu(); ! wxglade_tmp_menu_3->Append(ID_SIM_START, wxT("&Start"), wxT("Start simulation"), wxITEM_NORMAL); ! wxglade_tmp_menu_3->Append(ID_SIM_PAUSE, wxT("&Pause"), wxT("Pause Simulation"), wxITEM_NORMAL); ! MainFrame_menubar->Append(wxglade_tmp_menu_3, wxT("&Simulation")); MainFrame_statusbar = CreateStatusBar(1, 0); ! mCtrLocation = new wxTextCtrl(mLeftPane, -1, wxT("")); ! mCtrTree = new wxTreeCtrl(mLeftPane, 1, wxDefaultPosition, wxDefaultSize, wxTR_HAS_BUTTONS|wxTR_NO_LINES|wxTR_DEFAULT_STYLE|wxSUNKEN_BORDER); ! mCanvas = new SparkGLCanvas(mTopPane, -1); ! mCtrLog = new wxTextCtrl(mBottomPane, -1, wxT(""), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY|wxHSCROLL|wxTE_LINEWRAP); set_properties(); *************** *** 92,101 **** mToolBar->Realize(); ! // init vertical splitterwindow wxSize szClient = GetClientSize(); ! mCtrVertSplitter->SetSashPosition(std::max<int>(1,szClient.y - LOGWND_DEFAULT_HEIGHT)); ! // only resize top pane, when window is resized ! mCtrVertSplitter->SetSashGravity(1.0); // init log wnd timer --- 114,130 ---- mToolBar->Realize(); ! // ! // init horizontal splitterwindow (glcanvas / logwnd) wxSize szClient = GetClientSize(); ! mLastHorSashPosition = std::max<int>(1,szClient.y - LOGWND_DEFAULT_HEIGHT); ! SplitHor(); ! // init vertical splitterwindow ! mLastVertSashPosition = std::max<int>(1,TREEWND_DEFAULT_WIDTH); ! SplitVert(); ! ! // ! // init spark tree ! mSparkTree.Init(mCtrTree); // init log wnd timer *************** *** 103,106 **** --- 132,153 ---- } + void mainframe::SplitHor() + { + mCtrHorSplitter->SplitHorizontally(mTopPane, mBottomPane); + mCtrHorSplitter->SetSashPosition(mLastHorSashPosition); + + // only resize top pane, when window is resized + mCtrHorSplitter->SetSashGravity(1.0); + } + + void mainframe::SplitVert() + { + mCtrVertSplitter->SplitVertically(mLeftPane, mRightPane); + mCtrVertSplitter->SetSashPosition(mLastVertSashPosition); + + // only resize right pane when window is resized + mCtrVertSplitter->SetSashGravity(0.0); + } + void mainframe::set_properties() { *************** *** 123,139 **** // begin wxGlade: mainframe::do_layout wxBoxSizer* sizer_1 = new wxBoxSizer(wxVERTICAL); ! wxBoxSizer* sizer_4 = new wxBoxSizer(wxVERTICAL); ! wxBoxSizer* sizer_3 = new wxBoxSizer(wxHORIZONTAL); ! sizer_3->Add(mCanvas, 1, wxEXPAND, 0); ! window_1_pane_1->SetAutoLayout(true); ! window_1_pane_1->SetSizer(sizer_3); ! sizer_3->Fit(window_1_pane_1); ! sizer_3->SetSizeHints(window_1_pane_1); ! sizer_4->Add(mCtrLog, 1, wxEXPAND, 0); ! window_1_pane_2->SetAutoLayout(true); ! window_1_pane_2->SetSizer(sizer_4); ! sizer_4->Fit(window_1_pane_2); ! sizer_4->SetSizeHints(window_1_pane_2); ! mCtrVertSplitter->SplitHorizontally(window_1_pane_1, window_1_pane_2); sizer_1->Add(mCtrVertSplitter, 1, wxEXPAND, 0); SetAutoLayout(true); --- 170,200 ---- // begin wxGlade: mainframe::do_layout wxBoxSizer* sizer_1 = new wxBoxSizer(wxVERTICAL); ! wxBoxSizer* sizer_2 = new wxBoxSizer(wxVERTICAL); ! wxBoxSizer* sizer_6 = new wxBoxSizer(wxVERTICAL); ! wxBoxSizer* sizer_5 = new wxBoxSizer(wxVERTICAL); ! wxBoxSizer* sizer_7 = new wxBoxSizer(wxVERTICAL); ! sizer_7->Add(mCtrLocation, 0, wxEXPAND|wxADJUST_MINSIZE, 0); ! sizer_7->Add(mCtrTree, 1, wxEXPAND, 0); ! mLeftPane->SetAutoLayout(true); ! mLeftPane->SetSizer(sizer_7); ! sizer_7->Fit(mLeftPane); ! sizer_7->SetSizeHints(mLeftPane); ! sizer_5->Add(mCanvas, 1, wxEXPAND, 0); ! mTopPane->SetAutoLayout(true); ! mTopPane->SetSizer(sizer_5); ! sizer_5->Fit(mTopPane); ! sizer_5->SetSizeHints(mTopPane); ! sizer_6->Add(mCtrLog, 1, wxEXPAND, 0); ! mBottomPane->SetAutoLayout(true); ! mBottomPane->SetSizer(sizer_6); ! sizer_6->Fit(mBottomPane); ! sizer_6->SetSizeHints(mBottomPane); ! mCtrHorSplitter->SplitHorizontally(mTopPane, mBottomPane); ! sizer_2->Add(mCtrHorSplitter, 1, wxEXPAND, 0); ! mRightPane->SetAutoLayout(true); ! mRightPane->SetSizer(sizer_2); ! sizer_2->Fit(mRightPane); ! sizer_2->SetSizeHints(mRightPane); ! mCtrVertSplitter->SplitVertically(mLeftPane, mRightPane); sizer_1->Add(mCtrVertSplitter, 1, wxEXPAND, 0); SetAutoLayout(true); *************** *** 303,308 **** --- 364,420 ---- } + void mainframe::OnTreeItemExpanding(wxTreeEvent& event) + { + if (! mSparkTree.CreateChildren(event.GetItem())) + { + event.Veto(); + return; + } + } + void mainframe::OnTreeSelChanged(wxTreeEvent& event) + { + wxString location; + if (! mSparkTree.GetLocation(event.GetItem(), location)) + { + location = _T("?"); + } + + mCtrLocation->SetValue(location); + } + + + void mainframe::OnUpdateViewTree(wxUpdateUIEvent& event) + { + event.Check(mCtrVertSplitter->IsSplit()); + } + + void mainframe::OnViewTree(wxCommandEvent& event) + { + if (mCtrVertSplitter->IsSplit()) + { + mLastVertSashPosition = mCtrVertSplitter->GetSashPosition(); + mCtrVertSplitter->Unsplit(mLeftPane); + } else + { + SplitVert(); + } + } + void mainframe::OnUpdateViewLog(wxUpdateUIEvent& event) + { + event.Check(mCtrHorSplitter->IsSplit()); + } + void mainframe::OnViewLog(wxCommandEvent& event) + { + if (mCtrHorSplitter->IsSplit()) + { + mLastHorSashPosition = mCtrHorSplitter->GetSashPosition(); + mCtrHorSplitter->Unsplit(mBottomPane); + } else + { + SplitHor(); + } + } |