From: Markus R. <rol...@us...> - 2006-01-22 12:18:30
|
Update of /cvsroot/simspark/simspark/contrib/rsgedit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5861 Added Files: propertyframe.h propertyframe.cpp Log Message: - added class propertyframe that displays a list control with name/value pairs describing a zeitgeist class instance --- NEW FILE: propertyframe.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2003 Koblenz University $Id: propertyframe.h,v 1.1 2006/01/22 12:18:18 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ // -*- C++ -*- generated by wxGlade 0.4 on Sat Jan 21 16:34:57 2006 #include "property.h" #include <wx/wx.h> #include <wx/image.h> #ifndef PROPERTYFRAME_H #define PROPERTYFRAME_H // begin wxGlade: ::dependencies #include <wx/listctrl.h> // end wxGlade #include <boost/weak_ptr.hpp> namespace zeitgeist { class Leaf; } class propertyframe: public wxFrame { public: // begin wxGlade: propertyframe::ids // end wxGlade propertyframe(wxWindow* parent, int id, const wxString& title, const wxPoint& pos=wxDefaultPosition, const wxSize& size=wxDefaultSize, long style=wxDEFAULT_FRAME_STYLE); void SetLeaf(boost::weak_ptr<zeitgeist::Leaf> leaf); void InitList(); void RefreshProperties(); private: // begin wxGlade: propertyframe::methods void set_properties(); void do_layout(); // end wxGlade protected: // begin wxGlade: propertyframe::attributes wxListCtrl* mCtrList; // end wxGlade boost::weak_ptr<zeitgeist::Leaf> mLeaf; Property::TClassList mClassList; }; // wxGlade: end class #endif // PROPERTYFRAME_H --- NEW FILE: propertyframe.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2003 Koblenz University $Id: propertyframe.cpp,v 1.1 2006/01/22 12:18:18 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ // -*- C++ -*- generated by wxGlade 0.4 on Sat Jan 21 16:34:57 2006 #include "propertyframe.h" #include "main.h" //! wxWidgets and zeitgeist both use a 'DECLARE_CLASS' macro #undef DECLARE_CLASS #include <oxygen/sceneserver/basenode.h> using namespace boost; using namespace zeitgeist; propertyframe::propertyframe(wxWindow* parent, int id, const wxString& title, const wxPoint& pos, const wxSize& size, long style): wxFrame(parent, id, title, pos, size, wxCAPTION|wxCLOSE_BOX|wxMINIMIZE_BOX|wxMAXIMIZE_BOX|wxSYSTEM_MENU|wxRESIZE_BORDER|wxFRAME_TOOL_WINDOW|wxFRAME_FLOAT_ON_PARENT|wxCLIP_CHILDREN) { // begin wxGlade: propertyframe::propertyframe mCtrList = new wxListCtrl(this, -1, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxSUNKEN_BORDER); set_properties(); do_layout(); // end wxGlade } void propertyframe::set_properties() { // begin wxGlade: propertyframe::set_properties SetTitle(wxT("frame_1")); SetSize(wxSize(300, 150)); // end wxGlade } void propertyframe::do_layout() { // begin wxGlade: propertyframe::do_layout wxBoxSizer* sizer_3 = new wxBoxSizer(wxVERTICAL); sizer_3->Add(mCtrList, 1, wxEXPAND, 0); SetAutoLayout(true); SetSizer(sizer_3); Layout(); // end wxGlade } void propertyframe::SetLeaf(weak_ptr<Leaf> leaf) { mLeaf = leaf; shared_ptr<Property> property = wxGetApp().GetProperty(); if (property.get() != 0) { property->GetClassList(mLeaf.lock(), mClassList); } InitList(); } void propertyframe::RefreshProperties() { if (mLeaf.expired()) { return; } shared_ptr<Property> property = wxGetApp().GetProperty(); if (property.get() == 0) { return; } shared_ptr<Leaf> leaf = mLeaf.lock(); Property::TEntryList entries; property->GenEntries(leaf, mClassList, entries); int line = 0; bool valRefresh = (mCtrList->GetItemCount() == entries.size()); if (valRefresh) { // just refresh values to prevent flicker int line = 0; for ( Property::TEntryList::const_iterator iter = entries.begin(); iter != entries.end(); ++iter ) { const Property::Entry& entry = (*iter); mCtrList->SetItem(line, 1, entry.value); ++line; } } else { // complete refresh mCtrList->DeleteAllItems(); for ( Property::TEntryList::const_iterator iter = entries.begin(); iter != entries.end(); ++iter ) { const Property::Entry& entry = (*iter); int row = mCtrList->InsertItem(line, entry.name); mCtrList->SetItem(row, 1, entry.value); ++line; } } } void propertyframe::InitList() { mCtrList->ClearAll(); mCtrList->InsertColumn(0, _T("name"), wxLIST_FORMAT_LEFT, 120); mCtrList->InsertColumn(1, _T("value"), wxLIST_FORMAT_LEFT, 600); RefreshProperties(); } |