XMLID->XRCID, XMLCTRL->XRCCTRL
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13867 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -179,8 +179,8 @@ public:
|
|||||||
|
|
||||||
// Returns a numeric ID that is equivalent to the string id used in an XML
|
// Returns a numeric ID that is equivalent to the string id used in an XML
|
||||||
// resource. To be used in event tables.
|
// resource. To be used in event tables.
|
||||||
// Macro XMLID is provided for convenience
|
// Macro XRCID is provided for convenience
|
||||||
static int GetXMLID(const wxChar *str_id);
|
static int GetXRCID(const wxChar *str_id);
|
||||||
|
|
||||||
// Returns version information (a.b.c.d = d+ 256*c + 256^2*b + 256^3*a).
|
// Returns version information (a.b.c.d = d+ 256*c + 256^2*b + 256^3*a).
|
||||||
long GetVersion() const { return m_version; }
|
long GetVersion() const { return m_version; }
|
||||||
@@ -239,14 +239,14 @@ private:
|
|||||||
// wxWindows event tables.
|
// wxWindows event tables.
|
||||||
// Example:
|
// Example:
|
||||||
// BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
// BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||||
// EVT_MENU(XMLID("quit"), MyFrame::OnQuit)
|
// EVT_MENU(XRCID("quit"), MyFrame::OnQuit)
|
||||||
// EVT_MENU(XMLID("about"), MyFrame::OnAbout)
|
// EVT_MENU(XRCID("about"), MyFrame::OnAbout)
|
||||||
// EVT_MENU(XMLID("new"), MyFrame::OnNew)
|
// EVT_MENU(XRCID("new"), MyFrame::OnNew)
|
||||||
// EVT_MENU(XMLID("open"), MyFrame::OnOpen)
|
// EVT_MENU(XRCID("open"), MyFrame::OnOpen)
|
||||||
// END_EVENT_TABLE()
|
// END_EVENT_TABLE()
|
||||||
|
|
||||||
#define XMLID(str_id) \
|
#define XRCID(str_id) \
|
||||||
wxXmlResource::GetXMLID(wxT(str_id))
|
wxXmlResource::GetXRCID(wxT(str_id))
|
||||||
|
|
||||||
|
|
||||||
// This macro returns pointer to particular control in dialog
|
// This macro returns pointer to particular control in dialog
|
||||||
@@ -255,14 +255,14 @@ private:
|
|||||||
// Example:
|
// Example:
|
||||||
// wxDialog dlg;
|
// wxDialog dlg;
|
||||||
// wxXmlResource::Get()->LoadDialog(&dlg, mainFrame, "my_dialog");
|
// wxXmlResource::Get()->LoadDialog(&dlg, mainFrame, "my_dialog");
|
||||||
// XMLCTRL(dlg, "my_textctrl", wxTextCtrl)->SetValue(wxT("default value"));
|
// XRCCTRL(dlg, "my_textctrl", wxTextCtrl)->SetValue(wxT("default value"));
|
||||||
|
|
||||||
#ifdef __WXDEBUG__
|
#ifdef __WXDEBUG__
|
||||||
#define XMLCTRL(window, id, type) \
|
#define XRCCTRL(window, id, type) \
|
||||||
(wxDynamicCast((window).FindWindow(XMLID(id)), type))
|
(wxDynamicCast((window).FindWindow(XRCID(id)), type))
|
||||||
#else
|
#else
|
||||||
#define XMLCTRL(window, id, type) \
|
#define XRCCTRL(window, id, type) \
|
||||||
((type*)((window).FindWindow(XMLID(id))))
|
((type*)((window).FindWindow(XRCID(id))))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// wxXmlResourceHandler is an abstract base class for resource handlers
|
// wxXmlResourceHandler is an abstract base class for resource handlers
|
||||||
@@ -348,7 +348,7 @@ protected:
|
|||||||
// - calls wxGetTranslations (unless disabled in wxXmlResource)
|
// - calls wxGetTranslations (unless disabled in wxXmlResource)
|
||||||
wxString GetText(const wxString& param);
|
wxString GetText(const wxString& param);
|
||||||
|
|
||||||
// Returns the XMLID.
|
// Returns the XRCID.
|
||||||
int GetID();
|
int GetID();
|
||||||
|
|
||||||
// Returns the resource name.
|
// Returns the resource name.
|
||||||
@@ -426,7 +426,8 @@ void wxXmlInitResourceModule();
|
|||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
#define ADD_STYLE XRC_ADD_STYLE
|
#define ADD_STYLE XRC_ADD_STYLE
|
||||||
#define wxTheXmlResource wxXmlResource::Get()
|
#define wxTheXmlResource wxXmlResource::Get()
|
||||||
|
#define XMLID XRCID
|
||||||
|
#define XMLCTRL XRCCTRL
|
||||||
|
|
||||||
|
|
||||||
#endif // _WX_XMLRES_H_
|
#endif // _WX_XMLRES_H_
|
||||||
|
@@ -86,10 +86,10 @@ private:
|
|||||||
// handlers) which process them. It can be also done at run-time, but for the
|
// handlers) which process them. It can be also done at run-time, but for the
|
||||||
// simple menu events like this the static method is much simpler.
|
// simple menu events like this the static method is much simpler.
|
||||||
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||||
EVT_MENU(XMLID("menu_quit"), MyFrame::OnQuit)
|
EVT_MENU(XRCID("menu_quit"), MyFrame::OnQuit)
|
||||||
EVT_MENU(XMLID("menu_about"), MyFrame::OnAbout)
|
EVT_MENU(XRCID("menu_about"), MyFrame::OnAbout)
|
||||||
EVT_MENU(XMLID("menu_dlg1"), MyFrame::OnDlg1)
|
EVT_MENU(XRCID("menu_dlg1"), MyFrame::OnDlg1)
|
||||||
EVT_MENU(XMLID("menu_dlg2"), MyFrame::OnDlg2)
|
EVT_MENU(XRCID("menu_dlg2"), MyFrame::OnDlg2)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
// Create a new application object: this macro will allow wxWindows to create
|
// Create a new application object: this macro will allow wxWindows to create
|
||||||
|
@@ -58,7 +58,7 @@ void wxUnknownControlContainer::AddChild(wxWindowBase *child)
|
|||||||
|
|
||||||
SetBackgroundColour(m_bg);
|
SetBackgroundColour(m_bg);
|
||||||
child->SetName(m_controlName);
|
child->SetName(m_controlName);
|
||||||
child->SetId(wxXmlResource::GetXMLID(m_controlName));
|
child->SetId(wxXmlResource::GetXRCID(m_controlName));
|
||||||
m_controlAdded = TRUE;
|
m_controlAdded = TRUE;
|
||||||
|
|
||||||
wxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
|
wxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
@@ -713,7 +713,7 @@ int wxXmlResourceHandler::GetID()
|
|||||||
stdID(wxID_DEFAULT); stdID(wxID_MORE); stdID(wxID_SETUP);
|
stdID(wxID_DEFAULT); stdID(wxID_MORE); stdID(wxID_SETUP);
|
||||||
stdID(wxID_RESET); stdID(wxID_HELP_CONTEXT);
|
stdID(wxID_RESET); stdID(wxID_HELP_CONTEXT);
|
||||||
#undef stdID
|
#undef stdID
|
||||||
else return wxXmlResource::GetXMLID(sid);
|
else return wxXmlResource::GetXRCID(sid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1042,32 +1042,32 @@ void wxXmlResourceHandler::CreateChildrenPrivately(wxObject *parent, wxXmlNode *
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// --------------- XMLID implementation -----------------------------
|
// --------------- XRCID implementation -----------------------------
|
||||||
|
|
||||||
#define XMLID_TABLE_SIZE 1024
|
#define XRCID_TABLE_SIZE 1024
|
||||||
|
|
||||||
|
|
||||||
struct XMLID_record
|
struct XRCID_record
|
||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
wxChar *key;
|
wxChar *key;
|
||||||
XMLID_record *next;
|
XRCID_record *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
static XMLID_record *XMLID_Records[XMLID_TABLE_SIZE] = {NULL};
|
static XRCID_record *XRCID_Records[XRCID_TABLE_SIZE] = {NULL};
|
||||||
|
|
||||||
/*static*/ int wxXmlResource::GetXMLID(const wxChar *str_id)
|
/*static*/ int wxXmlResource::GetXRCID(const wxChar *str_id)
|
||||||
{
|
{
|
||||||
static int XMLID_LastID = wxID_HIGHEST;
|
static int XRCID_LastID = wxID_HIGHEST;
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
for (const wxChar *c = str_id; *c != wxT('\0'); c++) index += (int)*c;
|
for (const wxChar *c = str_id; *c != wxT('\0'); c++) index += (int)*c;
|
||||||
index %= XMLID_TABLE_SIZE;
|
index %= XRCID_TABLE_SIZE;
|
||||||
|
|
||||||
XMLID_record *oldrec = NULL;
|
XRCID_record *oldrec = NULL;
|
||||||
int matchcnt = 0;
|
int matchcnt = 0;
|
||||||
for (XMLID_record *rec = XMLID_Records[index]; rec; rec = rec->next)
|
for (XRCID_record *rec = XRCID_Records[index]; rec; rec = rec->next)
|
||||||
{
|
{
|
||||||
if (wxStrcmp(rec->key, str_id) == 0)
|
if (wxStrcmp(rec->key, str_id) == 0)
|
||||||
{
|
{
|
||||||
@@ -1077,10 +1077,10 @@ static XMLID_record *XMLID_Records[XMLID_TABLE_SIZE] = {NULL};
|
|||||||
oldrec = rec;
|
oldrec = rec;
|
||||||
}
|
}
|
||||||
|
|
||||||
XMLID_record **rec_var = (oldrec == NULL) ?
|
XRCID_record **rec_var = (oldrec == NULL) ?
|
||||||
&XMLID_Records[index] : &oldrec->next;
|
&XRCID_Records[index] : &oldrec->next;
|
||||||
*rec_var = new XMLID_record;
|
*rec_var = new XRCID_record;
|
||||||
(*rec_var)->id = ++XMLID_LastID;
|
(*rec_var)->id = ++XRCID_LastID;
|
||||||
(*rec_var)->key = wxStrdup(str_id);
|
(*rec_var)->key = wxStrdup(str_id);
|
||||||
(*rec_var)->next = NULL;
|
(*rec_var)->next = NULL;
|
||||||
|
|
||||||
@@ -1088,20 +1088,20 @@ static XMLID_record *XMLID_Records[XMLID_TABLE_SIZE] = {NULL};
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void CleanXMLID_Record(XMLID_record *rec)
|
static void CleanXRCID_Record(XRCID_record *rec)
|
||||||
{
|
{
|
||||||
if (rec)
|
if (rec)
|
||||||
{
|
{
|
||||||
CleanXMLID_Record(rec->next);
|
CleanXRCID_Record(rec->next);
|
||||||
free(rec->key);
|
free(rec->key);
|
||||||
delete rec;
|
delete rec;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CleanXMLID_Records()
|
static void CleanXRCID_Records()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < XMLID_TABLE_SIZE; i++)
|
for (int i = 0; i < XRCID_TABLE_SIZE; i++)
|
||||||
CleanXMLID_Record(XMLID_Records[i]);
|
CleanXRCID_Record(XRCID_Records[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1125,7 +1125,7 @@ public:
|
|||||||
void OnExit()
|
void OnExit()
|
||||||
{
|
{
|
||||||
delete wxXmlResource::Set(NULL);
|
delete wxXmlResource::Set(NULL);
|
||||||
CleanXMLID_Records();
|
CleanXRCID_Records();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -359,19 +359,19 @@ wxTreeItemId PropEditCtrlDim::CreateTreeEntry(wxTreeItemId parent, const Propert
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// --------------------- PropEditCtrlXMLID -----------------------------
|
// --------------------- PropEditCtrlXRCID -----------------------------
|
||||||
|
|
||||||
#define REAL_NODE (NodeHandler::Find(GetNode())->GetRealNode(GetNode()))
|
#define REAL_NODE (NodeHandler::Find(GetNode())->GetRealNode(GetNode()))
|
||||||
|
|
||||||
|
|
||||||
void PropEditCtrlXMLID::ReadValue()
|
void PropEditCtrlXRCID::ReadValue()
|
||||||
{
|
{
|
||||||
m_TextCtrl->SetValue(REAL_NODE->GetPropVal(_T("name"), wxEmptyString));
|
m_TextCtrl->SetValue(REAL_NODE->GetPropVal(_T("name"), wxEmptyString));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void PropEditCtrlXMLID::WriteValue()
|
void PropEditCtrlXRCID::WriteValue()
|
||||||
{
|
{
|
||||||
wxString s =m_TextCtrl->GetValue();
|
wxString s =m_TextCtrl->GetValue();
|
||||||
if (s.IsEmpty()) s = _T("-1");
|
if (s.IsEmpty()) s = _T("-1");
|
||||||
@@ -385,7 +385,7 @@ void PropEditCtrlXMLID::WriteValue()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void PropEditCtrlXMLID::Clear()
|
void PropEditCtrlXRCID::Clear()
|
||||||
{
|
{
|
||||||
EndEdit();
|
EndEdit();
|
||||||
REAL_NODE->DeleteProperty(_T("name"));
|
REAL_NODE->DeleteProperty(_T("name"));
|
||||||
@@ -395,7 +395,7 @@ void PropEditCtrlXMLID::Clear()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void PropEditCtrlXMLID::OnDetails()
|
void PropEditCtrlXRCID::OnDetails()
|
||||||
{
|
{
|
||||||
wxString choices[] = {wxString(_T("-1"))
|
wxString choices[] = {wxString(_T("-1"))
|
||||||
#define stdID(id) , wxString(#id)
|
#define stdID(id) , wxString(#id)
|
||||||
@@ -420,7 +420,7 @@ void PropEditCtrlXMLID::OnDetails()
|
|||||||
};
|
};
|
||||||
|
|
||||||
wxString s =
|
wxString s =
|
||||||
wxGetSingleChoice(_("Choose from predefined IDs:"), _("XMLID"),
|
wxGetSingleChoice(_("Choose from predefined IDs:"), _("XRCID"),
|
||||||
38/*sizeof choices*/, choices);
|
38/*sizeof choices*/, choices);
|
||||||
if (!s) return;
|
if (!s) return;
|
||||||
m_TextCtrl->SetValue(s);
|
m_TextCtrl->SetValue(s);
|
||||||
@@ -430,14 +430,14 @@ void PropEditCtrlXMLID::OnDetails()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
wxString PropEditCtrlXMLID::GetValueAsText(wxTreeItemId ti)
|
wxString PropEditCtrlXRCID::GetValueAsText(wxTreeItemId ti)
|
||||||
{
|
{
|
||||||
return REAL_NODE->GetPropVal(_T("name"), wxEmptyString);
|
return REAL_NODE->GetPropVal(_T("name"), wxEmptyString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool PropEditCtrlXMLID::IsPresent(const PropertyInfo& pinfo)
|
bool PropEditCtrlXRCID::IsPresent(const PropertyInfo& pinfo)
|
||||||
{
|
{
|
||||||
return REAL_NODE->HasProp(_T("name"));
|
return REAL_NODE->HasProp(_T("name"));
|
||||||
}
|
}
|
||||||
|
@@ -116,10 +116,10 @@ class PropEditCtrlDim : public PropEditCtrlTxt
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
class PropEditCtrlXMLID : public PropEditCtrlTxt
|
class PropEditCtrlXRCID : public PropEditCtrlTxt
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PropEditCtrlXMLID(PropertiesFrame *propFrame)
|
PropEditCtrlXRCID(PropertiesFrame *propFrame)
|
||||||
: PropEditCtrlTxt(propFrame) {}
|
: PropEditCtrlTxt(propFrame) {}
|
||||||
|
|
||||||
virtual void ReadValue();
|
virtual void ReadValue();
|
||||||
|
@@ -246,7 +246,7 @@ PropertiesFrame::PropertiesFrame()
|
|||||||
m_EditCtrls.Put(_T("integer"), new PropEditCtrlInt(this));
|
m_EditCtrls.Put(_T("integer"), new PropEditCtrlInt(this));
|
||||||
m_EditCtrls.Put(_T("not_implemented"), new PropEditCtrlNull(this));
|
m_EditCtrls.Put(_T("not_implemented"), new PropEditCtrlNull(this));
|
||||||
m_EditCtrls.Put(_T("text"), new PropEditCtrlTxt(this));
|
m_EditCtrls.Put(_T("text"), new PropEditCtrlTxt(this));
|
||||||
m_EditCtrls.Put(_T("xmlid"), new PropEditCtrlXMLID(this));
|
m_EditCtrls.Put(_T("xmlid"), new PropEditCtrlXRCID(this));
|
||||||
m_EditCtrls.Put(_T("font"), new PropEditCtrlFont(this));
|
m_EditCtrls.Put(_T("font"), new PropEditCtrlFont(this));
|
||||||
m_EditCtrls.Put(_T("choice"), new PropEditCtrlChoice(this));
|
m_EditCtrls.Put(_T("choice"), new PropEditCtrlChoice(this));
|
||||||
m_EditCtrls.Put(_T("file"), new PropEditCtrlFile(this));
|
m_EditCtrls.Put(_T("file"), new PropEditCtrlFile(this));
|
||||||
@@ -277,7 +277,7 @@ void PropertiesFrame::ShowProps(wxXmlNode *node)
|
|||||||
m_Node = node;
|
m_Node = node;
|
||||||
|
|
||||||
ClearProps();
|
ClearProps();
|
||||||
AddSingleProp(PropertyInfo(_T("xmlid"), _T("XMLID"), wxEmptyString));
|
AddSingleProp(PropertyInfo(_T("xmlid"), _T("XRCID"), wxEmptyString));
|
||||||
AddProps(NodeHandler::Find(node)->GetPropsList(node));
|
AddProps(NodeHandler::Find(node)->GetPropsList(node));
|
||||||
|
|
||||||
m_tree->Expand(m_tree->GetRootItem());
|
m_tree->Expand(m_tree->GetRootItem());
|
||||||
|
@@ -179,8 +179,8 @@ public:
|
|||||||
|
|
||||||
// Returns a numeric ID that is equivalent to the string id used in an XML
|
// Returns a numeric ID that is equivalent to the string id used in an XML
|
||||||
// resource. To be used in event tables.
|
// resource. To be used in event tables.
|
||||||
// Macro XMLID is provided for convenience
|
// Macro XRCID is provided for convenience
|
||||||
static int GetXMLID(const wxChar *str_id);
|
static int GetXRCID(const wxChar *str_id);
|
||||||
|
|
||||||
// Returns version information (a.b.c.d = d+ 256*c + 256^2*b + 256^3*a).
|
// Returns version information (a.b.c.d = d+ 256*c + 256^2*b + 256^3*a).
|
||||||
long GetVersion() const { return m_version; }
|
long GetVersion() const { return m_version; }
|
||||||
@@ -239,14 +239,14 @@ private:
|
|||||||
// wxWindows event tables.
|
// wxWindows event tables.
|
||||||
// Example:
|
// Example:
|
||||||
// BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
// BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||||
// EVT_MENU(XMLID("quit"), MyFrame::OnQuit)
|
// EVT_MENU(XRCID("quit"), MyFrame::OnQuit)
|
||||||
// EVT_MENU(XMLID("about"), MyFrame::OnAbout)
|
// EVT_MENU(XRCID("about"), MyFrame::OnAbout)
|
||||||
// EVT_MENU(XMLID("new"), MyFrame::OnNew)
|
// EVT_MENU(XRCID("new"), MyFrame::OnNew)
|
||||||
// EVT_MENU(XMLID("open"), MyFrame::OnOpen)
|
// EVT_MENU(XRCID("open"), MyFrame::OnOpen)
|
||||||
// END_EVENT_TABLE()
|
// END_EVENT_TABLE()
|
||||||
|
|
||||||
#define XMLID(str_id) \
|
#define XRCID(str_id) \
|
||||||
wxXmlResource::GetXMLID(wxT(str_id))
|
wxXmlResource::GetXRCID(wxT(str_id))
|
||||||
|
|
||||||
|
|
||||||
// This macro returns pointer to particular control in dialog
|
// This macro returns pointer to particular control in dialog
|
||||||
@@ -255,14 +255,14 @@ private:
|
|||||||
// Example:
|
// Example:
|
||||||
// wxDialog dlg;
|
// wxDialog dlg;
|
||||||
// wxXmlResource::Get()->LoadDialog(&dlg, mainFrame, "my_dialog");
|
// wxXmlResource::Get()->LoadDialog(&dlg, mainFrame, "my_dialog");
|
||||||
// XMLCTRL(dlg, "my_textctrl", wxTextCtrl)->SetValue(wxT("default value"));
|
// XRCCTRL(dlg, "my_textctrl", wxTextCtrl)->SetValue(wxT("default value"));
|
||||||
|
|
||||||
#ifdef __WXDEBUG__
|
#ifdef __WXDEBUG__
|
||||||
#define XMLCTRL(window, id, type) \
|
#define XRCCTRL(window, id, type) \
|
||||||
(wxDynamicCast((window).FindWindow(XMLID(id)), type))
|
(wxDynamicCast((window).FindWindow(XRCID(id)), type))
|
||||||
#else
|
#else
|
||||||
#define XMLCTRL(window, id, type) \
|
#define XRCCTRL(window, id, type) \
|
||||||
((type*)((window).FindWindow(XMLID(id))))
|
((type*)((window).FindWindow(XRCID(id))))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// wxXmlResourceHandler is an abstract base class for resource handlers
|
// wxXmlResourceHandler is an abstract base class for resource handlers
|
||||||
@@ -348,7 +348,7 @@ protected:
|
|||||||
// - calls wxGetTranslations (unless disabled in wxXmlResource)
|
// - calls wxGetTranslations (unless disabled in wxXmlResource)
|
||||||
wxString GetText(const wxString& param);
|
wxString GetText(const wxString& param);
|
||||||
|
|
||||||
// Returns the XMLID.
|
// Returns the XRCID.
|
||||||
int GetID();
|
int GetID();
|
||||||
|
|
||||||
// Returns the resource name.
|
// Returns the resource name.
|
||||||
@@ -426,7 +426,8 @@ void wxXmlInitResourceModule();
|
|||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
#define ADD_STYLE XRC_ADD_STYLE
|
#define ADD_STYLE XRC_ADD_STYLE
|
||||||
#define wxTheXmlResource wxXmlResource::Get()
|
#define wxTheXmlResource wxXmlResource::Get()
|
||||||
|
#define XMLID XRCID
|
||||||
|
#define XMLCTRL XRCCTRL
|
||||||
|
|
||||||
|
|
||||||
#endif // _WX_XMLRES_H_
|
#endif // _WX_XMLRES_H_
|
||||||
|
@@ -86,10 +86,10 @@ private:
|
|||||||
// handlers) which process them. It can be also done at run-time, but for the
|
// handlers) which process them. It can be also done at run-time, but for the
|
||||||
// simple menu events like this the static method is much simpler.
|
// simple menu events like this the static method is much simpler.
|
||||||
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||||
EVT_MENU(XMLID("menu_quit"), MyFrame::OnQuit)
|
EVT_MENU(XRCID("menu_quit"), MyFrame::OnQuit)
|
||||||
EVT_MENU(XMLID("menu_about"), MyFrame::OnAbout)
|
EVT_MENU(XRCID("menu_about"), MyFrame::OnAbout)
|
||||||
EVT_MENU(XMLID("menu_dlg1"), MyFrame::OnDlg1)
|
EVT_MENU(XRCID("menu_dlg1"), MyFrame::OnDlg1)
|
||||||
EVT_MENU(XMLID("menu_dlg2"), MyFrame::OnDlg2)
|
EVT_MENU(XRCID("menu_dlg2"), MyFrame::OnDlg2)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
// Create a new application object: this macro will allow wxWindows to create
|
// Create a new application object: this macro will allow wxWindows to create
|
||||||
|
@@ -58,7 +58,7 @@ void wxUnknownControlContainer::AddChild(wxWindowBase *child)
|
|||||||
|
|
||||||
SetBackgroundColour(m_bg);
|
SetBackgroundColour(m_bg);
|
||||||
child->SetName(m_controlName);
|
child->SetName(m_controlName);
|
||||||
child->SetId(wxXmlResource::GetXMLID(m_controlName));
|
child->SetId(wxXmlResource::GetXRCID(m_controlName));
|
||||||
m_controlAdded = TRUE;
|
m_controlAdded = TRUE;
|
||||||
|
|
||||||
wxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
|
wxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
@@ -713,7 +713,7 @@ int wxXmlResourceHandler::GetID()
|
|||||||
stdID(wxID_DEFAULT); stdID(wxID_MORE); stdID(wxID_SETUP);
|
stdID(wxID_DEFAULT); stdID(wxID_MORE); stdID(wxID_SETUP);
|
||||||
stdID(wxID_RESET); stdID(wxID_HELP_CONTEXT);
|
stdID(wxID_RESET); stdID(wxID_HELP_CONTEXT);
|
||||||
#undef stdID
|
#undef stdID
|
||||||
else return wxXmlResource::GetXMLID(sid);
|
else return wxXmlResource::GetXRCID(sid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1042,32 +1042,32 @@ void wxXmlResourceHandler::CreateChildrenPrivately(wxObject *parent, wxXmlNode *
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// --------------- XMLID implementation -----------------------------
|
// --------------- XRCID implementation -----------------------------
|
||||||
|
|
||||||
#define XMLID_TABLE_SIZE 1024
|
#define XRCID_TABLE_SIZE 1024
|
||||||
|
|
||||||
|
|
||||||
struct XMLID_record
|
struct XRCID_record
|
||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
wxChar *key;
|
wxChar *key;
|
||||||
XMLID_record *next;
|
XRCID_record *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
static XMLID_record *XMLID_Records[XMLID_TABLE_SIZE] = {NULL};
|
static XRCID_record *XRCID_Records[XRCID_TABLE_SIZE] = {NULL};
|
||||||
|
|
||||||
/*static*/ int wxXmlResource::GetXMLID(const wxChar *str_id)
|
/*static*/ int wxXmlResource::GetXRCID(const wxChar *str_id)
|
||||||
{
|
{
|
||||||
static int XMLID_LastID = wxID_HIGHEST;
|
static int XRCID_LastID = wxID_HIGHEST;
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
for (const wxChar *c = str_id; *c != wxT('\0'); c++) index += (int)*c;
|
for (const wxChar *c = str_id; *c != wxT('\0'); c++) index += (int)*c;
|
||||||
index %= XMLID_TABLE_SIZE;
|
index %= XRCID_TABLE_SIZE;
|
||||||
|
|
||||||
XMLID_record *oldrec = NULL;
|
XRCID_record *oldrec = NULL;
|
||||||
int matchcnt = 0;
|
int matchcnt = 0;
|
||||||
for (XMLID_record *rec = XMLID_Records[index]; rec; rec = rec->next)
|
for (XRCID_record *rec = XRCID_Records[index]; rec; rec = rec->next)
|
||||||
{
|
{
|
||||||
if (wxStrcmp(rec->key, str_id) == 0)
|
if (wxStrcmp(rec->key, str_id) == 0)
|
||||||
{
|
{
|
||||||
@@ -1077,10 +1077,10 @@ static XMLID_record *XMLID_Records[XMLID_TABLE_SIZE] = {NULL};
|
|||||||
oldrec = rec;
|
oldrec = rec;
|
||||||
}
|
}
|
||||||
|
|
||||||
XMLID_record **rec_var = (oldrec == NULL) ?
|
XRCID_record **rec_var = (oldrec == NULL) ?
|
||||||
&XMLID_Records[index] : &oldrec->next;
|
&XRCID_Records[index] : &oldrec->next;
|
||||||
*rec_var = new XMLID_record;
|
*rec_var = new XRCID_record;
|
||||||
(*rec_var)->id = ++XMLID_LastID;
|
(*rec_var)->id = ++XRCID_LastID;
|
||||||
(*rec_var)->key = wxStrdup(str_id);
|
(*rec_var)->key = wxStrdup(str_id);
|
||||||
(*rec_var)->next = NULL;
|
(*rec_var)->next = NULL;
|
||||||
|
|
||||||
@@ -1088,20 +1088,20 @@ static XMLID_record *XMLID_Records[XMLID_TABLE_SIZE] = {NULL};
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void CleanXMLID_Record(XMLID_record *rec)
|
static void CleanXRCID_Record(XRCID_record *rec)
|
||||||
{
|
{
|
||||||
if (rec)
|
if (rec)
|
||||||
{
|
{
|
||||||
CleanXMLID_Record(rec->next);
|
CleanXRCID_Record(rec->next);
|
||||||
free(rec->key);
|
free(rec->key);
|
||||||
delete rec;
|
delete rec;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CleanXMLID_Records()
|
static void CleanXRCID_Records()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < XMLID_TABLE_SIZE; i++)
|
for (int i = 0; i < XRCID_TABLE_SIZE; i++)
|
||||||
CleanXMLID_Record(XMLID_Records[i]);
|
CleanXRCID_Record(XRCID_Records[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1125,7 +1125,7 @@ public:
|
|||||||
void OnExit()
|
void OnExit()
|
||||||
{
|
{
|
||||||
delete wxXmlResource::Set(NULL);
|
delete wxXmlResource::Set(NULL);
|
||||||
CleanXMLID_Records();
|
CleanXRCID_Records();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user