1. minor rewrite of XRC's stock_id/stock_client handling, now guesses client id from context
2. fixed 'platform' property handling git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16637 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
6ada5c3359
commit
db59a97cda
@ -87,7 +87,7 @@ wxObject *wxMenuXmlHandler::DoCreateResource()
|
||||
|
||||
#if wxCHECK_VERSION(2,3,0) || defined(__WXMSW__)
|
||||
if (HasParam(wxT("bitmap")))
|
||||
mitem->SetBitmap(GetBitmap(wxT("bitmap")));
|
||||
mitem->SetBitmap(GetBitmap(wxT("bitmap"), wxART_MENU));
|
||||
#endif
|
||||
p_menu->Append(mitem);
|
||||
mitem->Enable(GetBool(wxT("enabled"), TRUE));
|
||||
|
@ -34,7 +34,7 @@ wxObject *wxStaticBitmapXmlHandler::DoCreateResource()
|
||||
|
||||
bmp->Create(m_parentAsWindow,
|
||||
GetID(),
|
||||
GetBitmap(wxT("bitmap"), GetSize()),
|
||||
GetBitmap(wxT("bitmap"), wxART_OTHER, GetSize()),
|
||||
GetPosition(), GetSize(),
|
||||
GetStyle(),
|
||||
GetName());
|
||||
|
@ -40,8 +40,8 @@ wxObject *wxToolBarXmlHandler::DoCreateResource()
|
||||
{
|
||||
wxCHECK_MSG(m_toolbar, NULL, wxT("Incorrect syntax of XRC resource: tool not within a toolbar!"));
|
||||
m_toolbar->AddTool(GetID(),
|
||||
GetBitmap(wxT("bitmap")),
|
||||
GetBitmap(wxT("bitmap2")),
|
||||
GetBitmap(wxT("bitmap"), wxART_TOOLBAR),
|
||||
GetBitmap(wxT("bitmap2"), wxART_TOOLBAR),
|
||||
GetBool(wxT("toggle")),
|
||||
GetPosition().x,
|
||||
GetPosition().y,
|
||||
|
@ -269,8 +269,8 @@ static void ProcessPlatformProperty(wxXmlNode *node)
|
||||
}
|
||||
else
|
||||
{
|
||||
node->RemoveChild(c);
|
||||
wxXmlNode *c2 = c->GetNext();
|
||||
node->RemoveChild(c);
|
||||
delete c;
|
||||
c = c2;
|
||||
}
|
||||
@ -719,67 +719,6 @@ int wxXmlResourceHandler::GetID()
|
||||
|
||||
|
||||
|
||||
wxArtID wxXmlResourceHandler::GetStockID(const wxString& param)
|
||||
{
|
||||
wxXmlNode *stockIDNode = GetParamNode(param);
|
||||
if (stockIDNode == NULL)
|
||||
return wxEmptyString;
|
||||
|
||||
wxXmlNode *oldnode = m_node;
|
||||
m_node = stockIDNode;
|
||||
|
||||
wxArtID sid = m_node->GetPropVal(wxT("stock_id"), wxT(""));
|
||||
|
||||
m_node = oldnode;
|
||||
|
||||
if (sid.IsEmpty()) return wxEmptyString;
|
||||
#define stdID(id) else if (sid == wxT(#id)) return id
|
||||
stdID(wxART_ADD_BOOKMARK); stdID(wxART_DEL_BOOKMARK);
|
||||
stdID(wxART_HELP_SIDE_PANEL); stdID(wxART_HELP_SETTINGS);
|
||||
stdID(wxART_HELP_BOOK); stdID(wxART_HELP_FOLDER);
|
||||
stdID(wxART_HELP_PAGE); stdID(wxART_GO_BACK);
|
||||
stdID(wxART_GO_FORWARD); stdID(wxART_GO_UP);
|
||||
stdID(wxART_GO_DOWN); stdID(wxART_GO_TO_PARENT);
|
||||
stdID(wxART_GO_HOME); stdID(wxART_FILE_OPEN);
|
||||
stdID(wxART_PRINT); stdID(wxART_HELP); stdID(wxART_TIP);
|
||||
stdID(wxART_REPORT_VIEW); stdID(wxART_LIST_VIEW);
|
||||
stdID(wxART_NEW_DIR); stdID(wxART_FOLDER);
|
||||
stdID(wxART_GO_DIR_UP); stdID(wxART_EXECUTABLE_FILE);
|
||||
stdID(wxART_NORMAL_FILE); stdID(wxART_TICK_MARK);
|
||||
stdID(wxART_CROSS_MARK); stdID(wxART_ERROR);
|
||||
stdID(wxART_QUESTION); stdID(wxART_WARNING);
|
||||
stdID(wxART_INFORMATION);
|
||||
#undef stdID
|
||||
else return sid;
|
||||
}
|
||||
|
||||
|
||||
|
||||
wxArtClient wxXmlResourceHandler::GetStockClient(const wxString& param)
|
||||
{
|
||||
wxXmlNode *stockClientNode = GetParamNode(param);
|
||||
if (stockClientNode == NULL)
|
||||
return wxEmptyString;
|
||||
|
||||
wxXmlNode *oldnode = m_node;
|
||||
m_node = stockClientNode;
|
||||
|
||||
wxArtClient sid = m_node->GetPropVal(wxT("stock_client"), wxT("wxART_OTHER"));
|
||||
|
||||
m_node = oldnode;
|
||||
|
||||
if (sid.IsEmpty()) return wxEmptyString;
|
||||
#define stdID(id) else if (sid == wxT(#id)) return id
|
||||
stdID(wxART_TOOLBAR); stdID(wxART_MENU);
|
||||
stdID(wxART_FRAME_ICON); stdID(wxART_CMN_DIALOG);
|
||||
stdID(wxART_HELP_BROWSER); stdID(wxART_MESSAGE_BOX);
|
||||
stdID(wxART_OTHER);
|
||||
#undef stdID
|
||||
else return sid;
|
||||
}
|
||||
|
||||
|
||||
|
||||
wxString wxXmlResourceHandler::GetName()
|
||||
{
|
||||
return m_node->GetPropVal(wxT("name"), wxT("-1"));
|
||||
@ -817,17 +756,28 @@ wxColour wxXmlResourceHandler::GetColour(const wxString& param)
|
||||
|
||||
|
||||
|
||||
wxBitmap wxXmlResourceHandler::GetBitmap(const wxString& param, wxSize size)
|
||||
wxBitmap wxXmlResourceHandler::GetBitmap(const wxString& param,
|
||||
const wxArtClient& defaultArtClient,
|
||||
wxSize size)
|
||||
{
|
||||
wxString stk = param;
|
||||
if (!GetStockID(stk).IsEmpty())
|
||||
/* If the bitmap is specified as stock item, query wxArtProvider for it: */
|
||||
wxXmlNode *bmpNode = GetParamNode(param);
|
||||
if ( bmpNode )
|
||||
{
|
||||
wxBitmap stockArt = wxArtProvider::GetBitmap(GetStockID(stk),
|
||||
GetStockClient(stk), size);
|
||||
if (stockArt != wxNullBitmap)
|
||||
return stockArt;
|
||||
wxString sid = bmpNode->GetPropVal(wxT("stock_id"), wxEmptyString);
|
||||
if ( !sid.empty() )
|
||||
{
|
||||
wxString scl = bmpNode->GetPropVal(wxT("stock_client"), defaultArtClient);
|
||||
wxBitmap stockArt =
|
||||
wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(sid),
|
||||
wxART_MAKE_CLIENT_ID_FROM_STR(scl),
|
||||
size);
|
||||
if ( stockArt.Ok() )
|
||||
return stockArt;
|
||||
}
|
||||
}
|
||||
|
||||
/* ...or load the bitmap from file: */
|
||||
wxString name = GetParamValue(param);
|
||||
if (name.IsEmpty()) return wxNullBitmap;
|
||||
#if wxUSE_FILESYSTEM
|
||||
@ -855,11 +805,13 @@ wxBitmap wxXmlResourceHandler::GetBitmap(const wxString& param, wxSize size)
|
||||
|
||||
|
||||
|
||||
wxIcon wxXmlResourceHandler::GetIcon(const wxString& param, wxSize size)
|
||||
wxIcon wxXmlResourceHandler::GetIcon(const wxString& param,
|
||||
const wxArtClient& defaultArtClient,
|
||||
wxSize size)
|
||||
{
|
||||
#if wxCHECK_VERSION(2,3,0) || defined(__WXMSW__)
|
||||
wxIcon icon;
|
||||
icon.CopyFromBitmap(GetBitmap(param, size));
|
||||
icon.CopyFromBitmap(GetBitmap(param, defaultArtClient, size));
|
||||
#else
|
||||
wxIcon *iconpt;
|
||||
wxBitmap bmppt = GetBitmap(param, size);
|
||||
|
@ -87,7 +87,7 @@ wxObject *wxMenuXmlHandler::DoCreateResource()
|
||||
|
||||
#if wxCHECK_VERSION(2,3,0) || defined(__WXMSW__)
|
||||
if (HasParam(wxT("bitmap")))
|
||||
mitem->SetBitmap(GetBitmap(wxT("bitmap")));
|
||||
mitem->SetBitmap(GetBitmap(wxT("bitmap"), wxART_MENU));
|
||||
#endif
|
||||
p_menu->Append(mitem);
|
||||
mitem->Enable(GetBool(wxT("enabled"), TRUE));
|
||||
|
@ -34,7 +34,7 @@ wxObject *wxStaticBitmapXmlHandler::DoCreateResource()
|
||||
|
||||
bmp->Create(m_parentAsWindow,
|
||||
GetID(),
|
||||
GetBitmap(wxT("bitmap"), GetSize()),
|
||||
GetBitmap(wxT("bitmap"), wxART_OTHER, GetSize()),
|
||||
GetPosition(), GetSize(),
|
||||
GetStyle(),
|
||||
GetName());
|
||||
|
@ -40,8 +40,8 @@ wxObject *wxToolBarXmlHandler::DoCreateResource()
|
||||
{
|
||||
wxCHECK_MSG(m_toolbar, NULL, wxT("Incorrect syntax of XRC resource: tool not within a toolbar!"));
|
||||
m_toolbar->AddTool(GetID(),
|
||||
GetBitmap(wxT("bitmap")),
|
||||
GetBitmap(wxT("bitmap2")),
|
||||
GetBitmap(wxT("bitmap"), wxART_TOOLBAR),
|
||||
GetBitmap(wxT("bitmap2"), wxART_TOOLBAR),
|
||||
GetBool(wxT("toggle")),
|
||||
GetPosition().x,
|
||||
GetPosition().y,
|
||||
|
@ -269,8 +269,8 @@ static void ProcessPlatformProperty(wxXmlNode *node)
|
||||
}
|
||||
else
|
||||
{
|
||||
node->RemoveChild(c);
|
||||
wxXmlNode *c2 = c->GetNext();
|
||||
node->RemoveChild(c);
|
||||
delete c;
|
||||
c = c2;
|
||||
}
|
||||
@ -719,67 +719,6 @@ int wxXmlResourceHandler::GetID()
|
||||
|
||||
|
||||
|
||||
wxArtID wxXmlResourceHandler::GetStockID(const wxString& param)
|
||||
{
|
||||
wxXmlNode *stockIDNode = GetParamNode(param);
|
||||
if (stockIDNode == NULL)
|
||||
return wxEmptyString;
|
||||
|
||||
wxXmlNode *oldnode = m_node;
|
||||
m_node = stockIDNode;
|
||||
|
||||
wxArtID sid = m_node->GetPropVal(wxT("stock_id"), wxT(""));
|
||||
|
||||
m_node = oldnode;
|
||||
|
||||
if (sid.IsEmpty()) return wxEmptyString;
|
||||
#define stdID(id) else if (sid == wxT(#id)) return id
|
||||
stdID(wxART_ADD_BOOKMARK); stdID(wxART_DEL_BOOKMARK);
|
||||
stdID(wxART_HELP_SIDE_PANEL); stdID(wxART_HELP_SETTINGS);
|
||||
stdID(wxART_HELP_BOOK); stdID(wxART_HELP_FOLDER);
|
||||
stdID(wxART_HELP_PAGE); stdID(wxART_GO_BACK);
|
||||
stdID(wxART_GO_FORWARD); stdID(wxART_GO_UP);
|
||||
stdID(wxART_GO_DOWN); stdID(wxART_GO_TO_PARENT);
|
||||
stdID(wxART_GO_HOME); stdID(wxART_FILE_OPEN);
|
||||
stdID(wxART_PRINT); stdID(wxART_HELP); stdID(wxART_TIP);
|
||||
stdID(wxART_REPORT_VIEW); stdID(wxART_LIST_VIEW);
|
||||
stdID(wxART_NEW_DIR); stdID(wxART_FOLDER);
|
||||
stdID(wxART_GO_DIR_UP); stdID(wxART_EXECUTABLE_FILE);
|
||||
stdID(wxART_NORMAL_FILE); stdID(wxART_TICK_MARK);
|
||||
stdID(wxART_CROSS_MARK); stdID(wxART_ERROR);
|
||||
stdID(wxART_QUESTION); stdID(wxART_WARNING);
|
||||
stdID(wxART_INFORMATION);
|
||||
#undef stdID
|
||||
else return sid;
|
||||
}
|
||||
|
||||
|
||||
|
||||
wxArtClient wxXmlResourceHandler::GetStockClient(const wxString& param)
|
||||
{
|
||||
wxXmlNode *stockClientNode = GetParamNode(param);
|
||||
if (stockClientNode == NULL)
|
||||
return wxEmptyString;
|
||||
|
||||
wxXmlNode *oldnode = m_node;
|
||||
m_node = stockClientNode;
|
||||
|
||||
wxArtClient sid = m_node->GetPropVal(wxT("stock_client"), wxT("wxART_OTHER"));
|
||||
|
||||
m_node = oldnode;
|
||||
|
||||
if (sid.IsEmpty()) return wxEmptyString;
|
||||
#define stdID(id) else if (sid == wxT(#id)) return id
|
||||
stdID(wxART_TOOLBAR); stdID(wxART_MENU);
|
||||
stdID(wxART_FRAME_ICON); stdID(wxART_CMN_DIALOG);
|
||||
stdID(wxART_HELP_BROWSER); stdID(wxART_MESSAGE_BOX);
|
||||
stdID(wxART_OTHER);
|
||||
#undef stdID
|
||||
else return sid;
|
||||
}
|
||||
|
||||
|
||||
|
||||
wxString wxXmlResourceHandler::GetName()
|
||||
{
|
||||
return m_node->GetPropVal(wxT("name"), wxT("-1"));
|
||||
@ -817,17 +756,28 @@ wxColour wxXmlResourceHandler::GetColour(const wxString& param)
|
||||
|
||||
|
||||
|
||||
wxBitmap wxXmlResourceHandler::GetBitmap(const wxString& param, wxSize size)
|
||||
wxBitmap wxXmlResourceHandler::GetBitmap(const wxString& param,
|
||||
const wxArtClient& defaultArtClient,
|
||||
wxSize size)
|
||||
{
|
||||
wxString stk = param;
|
||||
if (!GetStockID(stk).IsEmpty())
|
||||
/* If the bitmap is specified as stock item, query wxArtProvider for it: */
|
||||
wxXmlNode *bmpNode = GetParamNode(param);
|
||||
if ( bmpNode )
|
||||
{
|
||||
wxBitmap stockArt = wxArtProvider::GetBitmap(GetStockID(stk),
|
||||
GetStockClient(stk), size);
|
||||
if (stockArt != wxNullBitmap)
|
||||
return stockArt;
|
||||
wxString sid = bmpNode->GetPropVal(wxT("stock_id"), wxEmptyString);
|
||||
if ( !sid.empty() )
|
||||
{
|
||||
wxString scl = bmpNode->GetPropVal(wxT("stock_client"), defaultArtClient);
|
||||
wxBitmap stockArt =
|
||||
wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(sid),
|
||||
wxART_MAKE_CLIENT_ID_FROM_STR(scl),
|
||||
size);
|
||||
if ( stockArt.Ok() )
|
||||
return stockArt;
|
||||
}
|
||||
}
|
||||
|
||||
/* ...or load the bitmap from file: */
|
||||
wxString name = GetParamValue(param);
|
||||
if (name.IsEmpty()) return wxNullBitmap;
|
||||
#if wxUSE_FILESYSTEM
|
||||
@ -855,11 +805,13 @@ wxBitmap wxXmlResourceHandler::GetBitmap(const wxString& param, wxSize size)
|
||||
|
||||
|
||||
|
||||
wxIcon wxXmlResourceHandler::GetIcon(const wxString& param, wxSize size)
|
||||
wxIcon wxXmlResourceHandler::GetIcon(const wxString& param,
|
||||
const wxArtClient& defaultArtClient,
|
||||
wxSize size)
|
||||
{
|
||||
#if wxCHECK_VERSION(2,3,0) || defined(__WXMSW__)
|
||||
wxIcon icon;
|
||||
icon.CopyFromBitmap(GetBitmap(param, size));
|
||||
icon.CopyFromBitmap(GetBitmap(param, defaultArtClient, size));
|
||||
#else
|
||||
wxIcon *iconpt;
|
||||
wxBitmap bmppt = GetBitmap(param, size);
|
||||
|
Loading…
Reference in New Issue
Block a user