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();
|
2000-11-24 12:19:48 -05: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;
|
|
|
|
|
2000-11-04 18:34:33 -05:00
|
|
|
m_CanSave = FALSE;
|
|
|
|
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,
|
|
|
|
wxSize(16,-1)));
|
|
|
|
if (HasClearButton())
|
|
|
|
sz->Add(new wxButton(this, ID_CLEAR, _T("X"), wxDefaultPosition,
|
|
|
|
wxSize(16,-1)));
|
|
|
|
SetAutoLayout(TRUE);
|
|
|
|
SetSizer(sz);
|
|
|
|
m_Created = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_TheCtrl->SetFocus();
|
|
|
|
|
|
|
|
SetSize(rect.x, rect.y, rect.width, rect.height);
|
|
|
|
Show(TRUE);
|
|
|
|
ReadValue();
|
|
|
|
m_CanSave = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PropEditCtrl::EndEdit()
|
|
|
|
{
|
|
|
|
Show(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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))
|
|
|
|
m_TreeCtrl->SetItemBold(t, TRUE);
|
|
|
|
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;
|
|
|
|
m_TreeCtrl->SetItemBold(m_TreeItem, FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wxString PropEditCtrl::GetValueAsText(wxTreeItemId ti)
|
|
|
|
{
|
|
|
|
PropertyInfo& pir = ((PETreeData*)m_TreeCtrl->GetItemData(ti))->PropInfo;
|
|
|
|
return XmlReadValue(GetNode(), pir.Name);
|
|
|
|
}
|
|
|
|
|