]> git.saurik.com Git - wxWidgets.git/blame - contrib/utils/wxrcedit/propedit.cpp
added and documented SplitVolume() and GetPathTerminators(); corrected SetPath()...
[wxWidgets.git] / contrib / utils / wxrcedit / propedit.cpp
CommitLineData
12d9e308
VS
1/////////////////////////////////////////////////////////////////////////////
2// Author: Vaclav Slavik
3// Created: 2000/05/05
4// RCS-ID: $Id$
5// Copyright: (c) 2000 Vaclav Slavik
6// Licence: wxWindows licence
7/////////////////////////////////////////////////////////////////////////////
8
9#ifdef __GNUG__
10 #pragma implementation "propedit.h"
11#endif
12
13// For compilers that support precompilation, includes "wx/wx.h".
14#include "wx/wxprec.h"
15
16#ifdef __BORLANDC__
17 #pragma hdrstop
18#endif
19
20#include "wx/wx.h"
c74caa09 21#include "wx/xml/xml.h"
12d9e308
VS
22#include "propframe.h"
23#include "propedit.h"
24#include "xmlhelpr.h"
26607f41 25#include "editor.h"
12d9e308
VS
26
27enum
28{
29 ID_CLEAR = wxID_HIGHEST + 1,
30 ID_DETAILS
31};
32
33
34
35BEGIN_EVENT_TABLE(PropEditCtrl, wxPanel)
36 EVT_BUTTON(ID_CLEAR, PropEditCtrl::OnButtonClear)
37 EVT_BUTTON(ID_DETAILS, PropEditCtrl::OnButtonDetails)
38END_EVENT_TABLE()
39
859e5b17 40void PropEditCtrl::OnButtonDetails(wxCommandEvent& WXUNUSED(event))
12d9e308
VS
41{
42 OnDetails();
43}
44
859e5b17 45void PropEditCtrl::OnButtonClear(wxCommandEvent& WXUNUSED(event))
12d9e308
VS
46{
47 Clear();
f80ea77b 48 EditorFrame::Get()->NotifyChanged(CHANGED_PROPS);
12d9e308
VS
49}
50
51
52void PropEditCtrl::BeginEdit(const wxRect& rect, wxTreeItemId ti)
53{
a62da4c5
VS
54 m_PropInfo = &(((PETreeData*)m_TreeCtrl->GetItemData(ti))->PropInfo);
55 m_TreeItem = ti;
56
f80ea77b 57 m_CanSave = false;
12d9e308
VS
58 if (!m_Created)
59 {
60 wxSizer *sz = new wxBoxSizer(wxHORIZONTAL);
61 m_TheCtrl = CreateEditCtrl();
62 sz->Add(m_TheCtrl, 1);
63 if (HasDetails())
64 sz->Add(new wxButton(this, ID_DETAILS, _T("..."), wxDefaultPosition,
422d0ff0 65 wxSize(16,wxDefaultCoord)));
12d9e308
VS
66 if (HasClearButton())
67 sz->Add(new wxButton(this, ID_CLEAR, _T("X"), wxDefaultPosition,
422d0ff0 68 wxSize(16,wxDefaultCoord)));
12d9e308 69 SetSizer(sz);
f80ea77b 70 m_Created = true;
12d9e308
VS
71 }
72
73 m_TheCtrl->SetFocus();
74
12d9e308 75 SetSize(rect.x, rect.y, rect.width, rect.height);
f80ea77b 76 Show(true);
12d9e308 77 ReadValue();
f80ea77b 78 m_CanSave = true;
12d9e308
VS
79}
80
81
82
83void PropEditCtrl::EndEdit()
84{
f80ea77b 85 Show(false);
12d9e308
VS
86}
87
88
89
90wxTreeItemId PropEditCtrl::CreateTreeEntry(wxTreeItemId parent, const PropertyInfo& pinfo)
91{
92 wxTreeItemId t = m_TreeCtrl->AppendItem(parent, GetPropName(pinfo));
93 m_TreeCtrl->SetItemData(t, new PETreeData(this, pinfo));
94 if (IsPresent(pinfo))
f80ea77b 95 m_TreeCtrl->SetItemBold(t, true);
12d9e308
VS
96 return t;
97}
98
99bool PropEditCtrl::IsPresent(const PropertyInfo& pinfo)
100{
101 return XmlFindNode(GetNode(), pinfo.Name) != NULL;
102}
103
104
105
106void PropEditCtrl::Clear()
107{
108 EndEdit();
109
110 wxXmlNode *n = XmlFindNode(GetNode(), m_PropInfo->Name);
111 if (n)
112 {
113 n->GetParent()->RemoveChild(n);
114 delete n;
f80ea77b 115 m_TreeCtrl->SetItemBold(m_TreeItem, false);
12d9e308
VS
116 }
117}
118
119
120
121wxString PropEditCtrl::GetValueAsText(wxTreeItemId ti)
122{
123 PropertyInfo& pir = ((PETreeData*)m_TreeCtrl->GetItemData(ti))->PropInfo;
124 return XmlReadValue(GetNode(), pir.Name);
125}
126