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:
Václav Slavík 2002-01-27 23:42:16 +00:00
parent 20e453de9b
commit 5ed345b7ed
11 changed files with 96 additions and 94 deletions

View File

@ -179,8 +179,8 @@ public:
// Returns a numeric ID that is equivalent to the string id used in an XML
// resource. To be used in event tables.
// Macro XMLID is provided for convenience
static int GetXMLID(const wxChar *str_id);
// Macro XRCID is provided for convenience
static int GetXRCID(const wxChar *str_id);
// Returns version information (a.b.c.d = d+ 256*c + 256^2*b + 256^3*a).
long GetVersion() const { return m_version; }
@ -239,14 +239,14 @@ private:
// wxWindows event tables.
// Example:
// BEGIN_EVENT_TABLE(MyFrame, wxFrame)
// EVT_MENU(XMLID("quit"), MyFrame::OnQuit)
// EVT_MENU(XMLID("about"), MyFrame::OnAbout)
// EVT_MENU(XMLID("new"), MyFrame::OnNew)
// EVT_MENU(XMLID("open"), MyFrame::OnOpen)
// EVT_MENU(XRCID("quit"), MyFrame::OnQuit)
// EVT_MENU(XRCID("about"), MyFrame::OnAbout)
// EVT_MENU(XRCID("new"), MyFrame::OnNew)
// EVT_MENU(XRCID("open"), MyFrame::OnOpen)
// END_EVENT_TABLE()
#define XMLID(str_id) \
wxXmlResource::GetXMLID(wxT(str_id))
#define XRCID(str_id) \
wxXmlResource::GetXRCID(wxT(str_id))
// This macro returns pointer to particular control in dialog
@ -255,14 +255,14 @@ private:
// Example:
// wxDialog dlg;
// 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__
#define XMLCTRL(window, id, type) \
(wxDynamicCast((window).FindWindow(XMLID(id)), type))
#define XRCCTRL(window, id, type) \
(wxDynamicCast((window).FindWindow(XRCID(id)), type))
#else
#define XMLCTRL(window, id, type) \
((type*)((window).FindWindow(XMLID(id))))
#define XRCCTRL(window, id, type) \
((type*)((window).FindWindow(XRCID(id))))
#endif
// wxXmlResourceHandler is an abstract base class for resource handlers
@ -348,7 +348,7 @@ protected:
// - calls wxGetTranslations (unless disabled in wxXmlResource)
wxString GetText(const wxString& param);
// Returns the XMLID.
// Returns the XRCID.
int GetID();
// Returns the resource name.
@ -426,7 +426,8 @@ void wxXmlInitResourceModule();
------------------------------------------------------------------------- */
#define ADD_STYLE XRC_ADD_STYLE
#define wxTheXmlResource wxXmlResource::Get()
#define XMLID XRCID
#define XMLCTRL XRCCTRL
#endif // _WX_XMLRES_H_

View File

@ -86,10 +86,10 @@ private:
// 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.
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(XMLID("menu_quit"), MyFrame::OnQuit)
EVT_MENU(XMLID("menu_about"), MyFrame::OnAbout)
EVT_MENU(XMLID("menu_dlg1"), MyFrame::OnDlg1)
EVT_MENU(XMLID("menu_dlg2"), MyFrame::OnDlg2)
EVT_MENU(XRCID("menu_quit"), MyFrame::OnQuit)
EVT_MENU(XRCID("menu_about"), MyFrame::OnAbout)
EVT_MENU(XRCID("menu_dlg1"), MyFrame::OnDlg1)
EVT_MENU(XRCID("menu_dlg2"), MyFrame::OnDlg2)
END_EVENT_TABLE()
// Create a new application object: this macro will allow wxWindows to create

View File

@ -58,7 +58,7 @@ void wxUnknownControlContainer::AddChild(wxWindowBase *child)
SetBackgroundColour(m_bg);
child->SetName(m_controlName);
child->SetId(wxXmlResource::GetXMLID(m_controlName));
child->SetId(wxXmlResource::GetXRCID(m_controlName));
m_controlAdded = TRUE;
wxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);

View File

@ -713,7 +713,7 @@ int wxXmlResourceHandler::GetID()
stdID(wxID_DEFAULT); stdID(wxID_MORE); stdID(wxID_SETUP);
stdID(wxID_RESET); stdID(wxID_HELP_CONTEXT);
#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;
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;
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;
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)
{
@ -1077,10 +1077,10 @@ static XMLID_record *XMLID_Records[XMLID_TABLE_SIZE] = {NULL};
oldrec = rec;
}
XMLID_record **rec_var = (oldrec == NULL) ?
&XMLID_Records[index] : &oldrec->next;
*rec_var = new XMLID_record;
(*rec_var)->id = ++XMLID_LastID;
XRCID_record **rec_var = (oldrec == NULL) ?
&XRCID_Records[index] : &oldrec->next;
*rec_var = new XRCID_record;
(*rec_var)->id = ++XRCID_LastID;
(*rec_var)->key = wxStrdup(str_id);
(*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)
{
CleanXMLID_Record(rec->next);
CleanXRCID_Record(rec->next);
free(rec->key);
delete rec;
}
}
static void CleanXMLID_Records()
static void CleanXRCID_Records()
{
for (int i = 0; i < XMLID_TABLE_SIZE; i++)
CleanXMLID_Record(XMLID_Records[i]);
for (int i = 0; i < XRCID_TABLE_SIZE; i++)
CleanXRCID_Record(XRCID_Records[i]);
}
@ -1125,7 +1125,7 @@ public:
void OnExit()
{
delete wxXmlResource::Set(NULL);
CleanXMLID_Records();
CleanXRCID_Records();
}
};

View File

@ -359,19 +359,19 @@ wxTreeItemId PropEditCtrlDim::CreateTreeEntry(wxTreeItemId parent, const Propert
// --------------------- PropEditCtrlXMLID -----------------------------
// --------------------- PropEditCtrlXRCID -----------------------------
#define REAL_NODE (NodeHandler::Find(GetNode())->GetRealNode(GetNode()))
void PropEditCtrlXMLID::ReadValue()
void PropEditCtrlXRCID::ReadValue()
{
m_TextCtrl->SetValue(REAL_NODE->GetPropVal(_T("name"), wxEmptyString));
}
void PropEditCtrlXMLID::WriteValue()
void PropEditCtrlXRCID::WriteValue()
{
wxString s =m_TextCtrl->GetValue();
if (s.IsEmpty()) s = _T("-1");
@ -385,7 +385,7 @@ void PropEditCtrlXMLID::WriteValue()
void PropEditCtrlXMLID::Clear()
void PropEditCtrlXRCID::Clear()
{
EndEdit();
REAL_NODE->DeleteProperty(_T("name"));
@ -395,7 +395,7 @@ void PropEditCtrlXMLID::Clear()
void PropEditCtrlXMLID::OnDetails()
void PropEditCtrlXRCID::OnDetails()
{
wxString choices[] = {wxString(_T("-1"))
#define stdID(id) , wxString(#id)
@ -420,7 +420,7 @@ void PropEditCtrlXMLID::OnDetails()
};
wxString s =
wxGetSingleChoice(_("Choose from predefined IDs:"), _("XMLID"),
wxGetSingleChoice(_("Choose from predefined IDs:"), _("XRCID"),
38/*sizeof choices*/, choices);
if (!s) return;
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);
}
bool PropEditCtrlXMLID::IsPresent(const PropertyInfo& pinfo)
bool PropEditCtrlXRCID::IsPresent(const PropertyInfo& pinfo)
{
return REAL_NODE->HasProp(_T("name"));
}

View File

@ -116,10 +116,10 @@ class PropEditCtrlDim : public PropEditCtrlTxt
class PropEditCtrlXMLID : public PropEditCtrlTxt
class PropEditCtrlXRCID : public PropEditCtrlTxt
{
public:
PropEditCtrlXMLID(PropertiesFrame *propFrame)
PropEditCtrlXRCID(PropertiesFrame *propFrame)
: PropEditCtrlTxt(propFrame) {}
virtual void ReadValue();

View File

@ -246,7 +246,7 @@ PropertiesFrame::PropertiesFrame()
m_EditCtrls.Put(_T("integer"), new PropEditCtrlInt(this));
m_EditCtrls.Put(_T("not_implemented"), new PropEditCtrlNull(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("choice"), new PropEditCtrlChoice(this));
m_EditCtrls.Put(_T("file"), new PropEditCtrlFile(this));
@ -277,7 +277,7 @@ void PropertiesFrame::ShowProps(wxXmlNode *node)
m_Node = node;
ClearProps();
AddSingleProp(PropertyInfo(_T("xmlid"), _T("XMLID"), wxEmptyString));
AddSingleProp(PropertyInfo(_T("xmlid"), _T("XRCID"), wxEmptyString));
AddProps(NodeHandler::Find(node)->GetPropsList(node));
m_tree->Expand(m_tree->GetRootItem());

View File

@ -179,8 +179,8 @@ public:
// Returns a numeric ID that is equivalent to the string id used in an XML
// resource. To be used in event tables.
// Macro XMLID is provided for convenience
static int GetXMLID(const wxChar *str_id);
// Macro XRCID is provided for convenience
static int GetXRCID(const wxChar *str_id);
// Returns version information (a.b.c.d = d+ 256*c + 256^2*b + 256^3*a).
long GetVersion() const { return m_version; }
@ -239,14 +239,14 @@ private:
// wxWindows event tables.
// Example:
// BEGIN_EVENT_TABLE(MyFrame, wxFrame)
// EVT_MENU(XMLID("quit"), MyFrame::OnQuit)
// EVT_MENU(XMLID("about"), MyFrame::OnAbout)
// EVT_MENU(XMLID("new"), MyFrame::OnNew)
// EVT_MENU(XMLID("open"), MyFrame::OnOpen)
// EVT_MENU(XRCID("quit"), MyFrame::OnQuit)
// EVT_MENU(XRCID("about"), MyFrame::OnAbout)
// EVT_MENU(XRCID("new"), MyFrame::OnNew)
// EVT_MENU(XRCID("open"), MyFrame::OnOpen)
// END_EVENT_TABLE()
#define XMLID(str_id) \
wxXmlResource::GetXMLID(wxT(str_id))
#define XRCID(str_id) \
wxXmlResource::GetXRCID(wxT(str_id))
// This macro returns pointer to particular control in dialog
@ -255,14 +255,14 @@ private:
// Example:
// wxDialog dlg;
// 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__
#define XMLCTRL(window, id, type) \
(wxDynamicCast((window).FindWindow(XMLID(id)), type))
#define XRCCTRL(window, id, type) \
(wxDynamicCast((window).FindWindow(XRCID(id)), type))
#else
#define XMLCTRL(window, id, type) \
((type*)((window).FindWindow(XMLID(id))))
#define XRCCTRL(window, id, type) \
((type*)((window).FindWindow(XRCID(id))))
#endif
// wxXmlResourceHandler is an abstract base class for resource handlers
@ -348,7 +348,7 @@ protected:
// - calls wxGetTranslations (unless disabled in wxXmlResource)
wxString GetText(const wxString& param);
// Returns the XMLID.
// Returns the XRCID.
int GetID();
// Returns the resource name.
@ -426,7 +426,8 @@ void wxXmlInitResourceModule();
------------------------------------------------------------------------- */
#define ADD_STYLE XRC_ADD_STYLE
#define wxTheXmlResource wxXmlResource::Get()
#define XMLID XRCID
#define XMLCTRL XRCCTRL
#endif // _WX_XMLRES_H_

View File

@ -86,10 +86,10 @@ private:
// 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.
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(XMLID("menu_quit"), MyFrame::OnQuit)
EVT_MENU(XMLID("menu_about"), MyFrame::OnAbout)
EVT_MENU(XMLID("menu_dlg1"), MyFrame::OnDlg1)
EVT_MENU(XMLID("menu_dlg2"), MyFrame::OnDlg2)
EVT_MENU(XRCID("menu_quit"), MyFrame::OnQuit)
EVT_MENU(XRCID("menu_about"), MyFrame::OnAbout)
EVT_MENU(XRCID("menu_dlg1"), MyFrame::OnDlg1)
EVT_MENU(XRCID("menu_dlg2"), MyFrame::OnDlg2)
END_EVENT_TABLE()
// Create a new application object: this macro will allow wxWindows to create

View File

@ -58,7 +58,7 @@ void wxUnknownControlContainer::AddChild(wxWindowBase *child)
SetBackgroundColour(m_bg);
child->SetName(m_controlName);
child->SetId(wxXmlResource::GetXMLID(m_controlName));
child->SetId(wxXmlResource::GetXRCID(m_controlName));
m_controlAdded = TRUE;
wxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);

View File

@ -713,7 +713,7 @@ int wxXmlResourceHandler::GetID()
stdID(wxID_DEFAULT); stdID(wxID_MORE); stdID(wxID_SETUP);
stdID(wxID_RESET); stdID(wxID_HELP_CONTEXT);
#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;
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;
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;
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)
{
@ -1077,10 +1077,10 @@ static XMLID_record *XMLID_Records[XMLID_TABLE_SIZE] = {NULL};
oldrec = rec;
}
XMLID_record **rec_var = (oldrec == NULL) ?
&XMLID_Records[index] : &oldrec->next;
*rec_var = new XMLID_record;
(*rec_var)->id = ++XMLID_LastID;
XRCID_record **rec_var = (oldrec == NULL) ?
&XRCID_Records[index] : &oldrec->next;
*rec_var = new XRCID_record;
(*rec_var)->id = ++XRCID_LastID;
(*rec_var)->key = wxStrdup(str_id);
(*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)
{
CleanXMLID_Record(rec->next);
CleanXRCID_Record(rec->next);
free(rec->key);
delete rec;
}
}
static void CleanXMLID_Records()
static void CleanXRCID_Records()
{
for (int i = 0; i < XMLID_TABLE_SIZE; i++)
CleanXMLID_Record(XMLID_Records[i]);
for (int i = 0; i < XRCID_TABLE_SIZE; i++)
CleanXRCID_Record(XRCID_Records[i]);
}
@ -1125,7 +1125,7 @@ public:
void OnExit()
{
delete wxXmlResource::Set(NULL);
CleanXMLID_Records();
CleanXRCID_Records();
}
};