2000-11-04 18:34:33 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Author: Vaclav Slavik
|
|
|
|
// Created: 2000/05/05
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) 2000 Vaclav Slavik
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation "propedit.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// For compilers that support precompilation, includes "wx/wx.h".
|
|
|
|
#include "wx/wxprec.h"
|
|
|
|
|
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#pragma hdrstop
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "wx/wx.h"
|
2003-09-10 16:53:01 -04:00
|
|
|
#include "wx/xml/xml.h"
|
2000-11-04 18:34:33 -05:00
|
|
|
#include "propframe.h"
|
|
|
|
#include "propedit.h"
|
|
|
|
#include "xmlhelpr.h"
|
2000-11-24 12:19:48 -05:00
|
|
|
#include "editor.h"
|
2000-11-04 18:34:33 -05:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
ID_CLEAR = wxID_HIGHEST + 1,
|
|
|
|
ID_DETAILS
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE(PropEditCtrl, wxPanel)
|
|
|
|
EVT_BUTTON(ID_CLEAR, PropEditCtrl::OnButtonClear)
|
|
|
|
EVT_BUTTON(ID_DETAILS, PropEditCtrl::OnButtonDetails)
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
2003-09-18 09:47:05 -04:00
|
|
|
void PropEditCtrl::OnButtonDetails(wxCommandEvent& WXUNUSED(event))
|
2000-11-04 18:34:33 -05:00
|
|
|
{
|
|
|
|
OnDetails();
|
|
|
|
}
|
|
|
|
|
2003-09-18 09:47:05 -04:00
|
|
|
void PropEditCtrl::OnButtonClear(wxCommandEvent& WXUNUSED(event))
|
2000-11-04 18:34:33 -05:00
|
|
|
{
|
|
|
|
Clear();
|
2004-06-11 09:14:23 -04:00
|
|
|
EditorFrame::Get()->NotifyChanged(CHANGED_PROPS);
|
2000-11-04 18:34:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PropEditCtrl::BeginEdit(const wxRect& rect, wxTreeItemId ti)
|
|
|
|
{
|
2000-11-05 17:50:58 -05:00
|
|
|
m_PropInfo = &(((PETreeData*)m_TreeCtrl->GetItemData(ti))->PropInfo);
|
|
|
|
m_TreeItem = ti;
|
|
|
|
|
2004-06-11 09:14:23 -04:00
|
|
|
m_CanSave = false;
|
2000-11-04 18:34:33 -05:00
|
|
|
if (!m_Created)
|
|
|
|
{
|
|
|
|
wxSizer *sz = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
m_TheCtrl = CreateEditCtrl();
|
|
|
|
sz->Add(m_TheCtrl, 1);
|
|
|
|
if (HasDetails())
|
|
|
|
sz->Add(new wxButton(this, ID_DETAILS, _T("..."), wxDefaultPosition,
|
2004-07-20 06:09:47 -04:00
|
|
|
wxSize(16,wxDefaultCoord)));
|
2000-11-04 18:34:33 -05:00
|
|
|
if (HasClearButton())
|
|
|
|
sz->Add(new wxButton(this, ID_CLEAR, _T("X"), wxDefaultPosition,
|
2004-07-20 06:09:47 -04:00
|
|
|
wxSize(16,wxDefaultCoord)));
|
2000-11-04 18:34:33 -05:00
|
|
|
SetSizer(sz);
|
2004-06-11 09:14:23 -04:00
|
|
|
m_Created = true;
|
2000-11-04 18:34:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
m_TheCtrl->SetFocus();
|
|
|
|
|
|
|
|
SetSize(rect.x, rect.y, rect.width, rect.height);
|
2004-06-11 09:14:23 -04:00
|
|
|
Show(true);
|
2000-11-04 18:34:33 -05:00
|
|
|
ReadValue();
|
2004-06-11 09:14:23 -04:00
|
|
|
m_CanSave = true;
|
2000-11-04 18:34:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PropEditCtrl::EndEdit()
|
|
|
|
{
|
2004-06-11 09:14:23 -04:00
|
|
|
Show(false);
|
2000-11-04 18:34:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wxTreeItemId PropEditCtrl::CreateTreeEntry(wxTreeItemId parent, const PropertyInfo& pinfo)
|
|
|
|
{
|
|
|
|
wxTreeItemId t = m_TreeCtrl->AppendItem(parent, GetPropName(pinfo));
|
|
|
|
m_TreeCtrl->SetItemData(t, new PETreeData(this, pinfo));
|
|
|
|
if (IsPresent(pinfo))
|
2004-06-11 09:14:23 -04:00
|
|
|
m_TreeCtrl->SetItemBold(t, true);
|
2000-11-04 18:34:33 -05:00
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PropEditCtrl::IsPresent(const PropertyInfo& pinfo)
|
|
|
|
{
|
|
|
|
return XmlFindNode(GetNode(), pinfo.Name) != NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PropEditCtrl::Clear()
|
|
|
|
{
|
|
|
|
EndEdit();
|
|
|
|
|
|
|
|
wxXmlNode *n = XmlFindNode(GetNode(), m_PropInfo->Name);
|
|
|
|
if (n)
|
|
|
|
{
|
|
|
|
n->GetParent()->RemoveChild(n);
|
|
|
|
delete n;
|
2004-06-11 09:14:23 -04:00
|
|
|
m_TreeCtrl->SetItemBold(m_TreeItem, false);
|
2000-11-04 18:34:33 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wxString PropEditCtrl::GetValueAsText(wxTreeItemId ti)
|
|
|
|
{
|
|
|
|
PropertyInfo& pir = ((PETreeData*)m_TreeCtrl->GetItemData(ti))->PropInfo;
|
|
|
|
return XmlReadValue(GetNode(), pir.Name);
|
|
|
|
}
|
|
|
|
|