wxWidgets/contrib/utils/wxrcedit/propedit.cpp
Mattia Barbon c74caa095c Added bakefiles for contrib/utils/convertrc and contrib/utils/wxrcedit
and regenerated makefiles.
  various compilation and warning fixes for recent changes and for
WXWIN_COMPATIBILITY_2_4==0.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23486 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2003-09-10 20:53:01 +00:00

128 lines
2.8 KiB
C++

/////////////////////////////////////////////////////////////////////////////
// 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"
#include "wx/xml/xml.h"
#include "propframe.h"
#include "propedit.h"
#include "xmlhelpr.h"
#include "editor.h"
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()
void PropEditCtrl::OnButtonDetails(wxCommandEvent& event)
{
OnDetails();
}
void PropEditCtrl::OnButtonClear(wxCommandEvent& event)
{
Clear();
EditorFrame::Get()->NotifyChanged(CHANGED_PROPS);
}
void PropEditCtrl::BeginEdit(const wxRect& rect, wxTreeItemId ti)
{
m_PropInfo = &(((PETreeData*)m_TreeCtrl->GetItemData(ti))->PropInfo);
m_TreeItem = ti;
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);
}