]>
git.saurik.com Git - wxWidgets.git/blob - contrib/utils/wxrcedit/propedit.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Author: Vaclav Slavik
5 // Copyright: (c) 2000 Vaclav Slavik
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
10 #pragma implementation "propedit.h"
13 // For compilers that support precompilation, includes "wx/wx.h".
14 #include "wx/wxprec.h"
21 #include "wx/xml/xml.h"
22 #include "propframe.h"
29 ID_CLEAR
= wxID_HIGHEST
+ 1,
35 BEGIN_EVENT_TABLE(PropEditCtrl
, wxPanel
)
36 EVT_BUTTON(ID_CLEAR
, PropEditCtrl::OnButtonClear
)
37 EVT_BUTTON(ID_DETAILS
, PropEditCtrl::OnButtonDetails
)
40 void PropEditCtrl::OnButtonDetails(wxCommandEvent
& WXUNUSED(event
))
45 void PropEditCtrl::OnButtonClear(wxCommandEvent
& WXUNUSED(event
))
48 EditorFrame::Get()->NotifyChanged(CHANGED_PROPS
);
52 void PropEditCtrl::BeginEdit(const wxRect
& rect
, wxTreeItemId ti
)
54 m_PropInfo
= &(((PETreeData
*)m_TreeCtrl
->GetItemData(ti
))->PropInfo
);
60 wxSizer
*sz
= new wxBoxSizer(wxHORIZONTAL
);
61 m_TheCtrl
= CreateEditCtrl();
62 sz
->Add(m_TheCtrl
, 1);
64 sz
->Add(new wxButton(this, ID_DETAILS
, _T("..."), wxDefaultPosition
,
65 wxSize(16,wxDefaultSize
.y
)));
67 sz
->Add(new wxButton(this, ID_CLEAR
, _T("X"), wxDefaultPosition
,
68 wxSize(16,wxDefaultSize
.y
)));
74 m_TheCtrl
->SetFocus();
76 SetSize(rect
.x
, rect
.y
, rect
.width
, rect
.height
);
84 void PropEditCtrl::EndEdit()
91 wxTreeItemId
PropEditCtrl::CreateTreeEntry(wxTreeItemId parent
, const PropertyInfo
& pinfo
)
93 wxTreeItemId t
= m_TreeCtrl
->AppendItem(parent
, GetPropName(pinfo
));
94 m_TreeCtrl
->SetItemData(t
, new PETreeData(this, pinfo
));
96 m_TreeCtrl
->SetItemBold(t
, true);
100 bool PropEditCtrl::IsPresent(const PropertyInfo
& pinfo
)
102 return XmlFindNode(GetNode(), pinfo
.Name
) != NULL
;
107 void PropEditCtrl::Clear()
111 wxXmlNode
*n
= XmlFindNode(GetNode(), m_PropInfo
->Name
);
114 n
->GetParent()->RemoveChild(n
);
116 m_TreeCtrl
->SetItemBold(m_TreeItem
, false);
122 wxString
PropEditCtrl::GetValueAsText(wxTreeItemId ti
)
124 PropertyInfo
& pir
= ((PETreeData
*)m_TreeCtrl
->GetItemData(ti
))->PropInfo
;
125 return XmlReadValue(GetNode(), pir
.Name
);