No changes, just factor our wxDirection parsing code in wxXRC.
Move it from wxButtonXmlHandler into a reusable wxXmlResourceHandler:: GetDirection() that can used by the other handlers too. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68839 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -558,6 +558,9 @@ protected:
|
|||||||
wxCoord GetDimension(const wxString& param, wxCoord defaultv = 0,
|
wxCoord GetDimension(const wxString& param, wxCoord defaultv = 0,
|
||||||
wxWindow *windowToUse = NULL);
|
wxWindow *windowToUse = NULL);
|
||||||
|
|
||||||
|
// Gets a direction, complains if the value is invalid.
|
||||||
|
wxDirection GetDirection(const wxString& param, wxDirection dir = wxLEFT);
|
||||||
|
|
||||||
// Gets a bitmap.
|
// Gets a bitmap.
|
||||||
wxBitmap GetBitmap(const wxString& param = wxT("bitmap"),
|
wxBitmap GetBitmap(const wxString& param = wxT("bitmap"),
|
||||||
const wxArtClient& defaultArtClient = wxART_OTHER,
|
const wxArtClient& defaultArtClient = wxART_OTHER,
|
||||||
|
@@ -553,6 +553,18 @@ protected:
|
|||||||
wxCoord GetDimension(const wxString& param, wxCoord defaultv = 0,
|
wxCoord GetDimension(const wxString& param, wxCoord defaultv = 0,
|
||||||
wxWindow* windowToUse = 0);
|
wxWindow* windowToUse = 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Gets a direction.
|
||||||
|
|
||||||
|
If the given @a param is not present or has empty value, @a dir is
|
||||||
|
returned by default. Otherwise the value of the parameter is parsed and
|
||||||
|
a warning is generated if it's not one of @c wxLEFT, @c wxTOP, @c
|
||||||
|
wxRIGHT or @c wxBOTTOM.
|
||||||
|
|
||||||
|
@since 2.9.3
|
||||||
|
*/
|
||||||
|
wxDirection GetDirection(const wxString& param, wxDirection dir = wxLEFT);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Gets a font.
|
Gets a font.
|
||||||
*/
|
*/
|
||||||
|
@@ -53,33 +53,8 @@ wxObject *wxButtonXmlHandler::DoCreateResource()
|
|||||||
|
|
||||||
if ( GetParamNode("bitmap") )
|
if ( GetParamNode("bitmap") )
|
||||||
{
|
{
|
||||||
wxDirection dir;
|
button->SetBitmap(GetBitmap("bitmap", wxART_BUTTON),
|
||||||
const wxString dirstr = GetParamValue("bitmapposition");
|
GetDirection("bitmapposition"));
|
||||||
if ( dirstr.empty() || dirstr == "wxLEFT" )
|
|
||||||
dir = wxLEFT;
|
|
||||||
else if ( dirstr == "wxRIGHT" )
|
|
||||||
dir = wxRIGHT;
|
|
||||||
else if ( dirstr == "wxTOP" )
|
|
||||||
dir = wxTOP;
|
|
||||||
else if ( dirstr == "wxBOTTOM" )
|
|
||||||
dir = wxBOTTOM;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ReportError
|
|
||||||
(
|
|
||||||
GetParamNode("bitmapposition"),
|
|
||||||
wxString::Format
|
|
||||||
(
|
|
||||||
"Invalid bitmap position \"%s\": must be one of "
|
|
||||||
"wxLEFT|wxRIGHT|wxTOP|wxBOTTOM.",
|
|
||||||
dirstr
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
dir = wxLEFT;
|
|
||||||
}
|
|
||||||
|
|
||||||
button->SetBitmap(GetBitmap("bitmap", wxART_BUTTON), dir);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SetupWindow(button);
|
SetupWindow(button);
|
||||||
|
@@ -2150,6 +2150,40 @@ wxCoord wxXmlResourceHandler::GetDimension(const wxString& param,
|
|||||||
return sx;
|
return sx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxDirection
|
||||||
|
wxXmlResourceHandler::GetDirection(const wxString& param, wxDirection dirDefault)
|
||||||
|
{
|
||||||
|
wxDirection dir;
|
||||||
|
|
||||||
|
const wxString dirstr = GetParamValue(param);
|
||||||
|
if ( dirstr.empty() )
|
||||||
|
dir = dirDefault;
|
||||||
|
else if ( dirstr == "wxLEFT" )
|
||||||
|
dir = wxLEFT;
|
||||||
|
else if ( dirstr == "wxRIGHT" )
|
||||||
|
dir = wxRIGHT;
|
||||||
|
else if ( dirstr == "wxTOP" )
|
||||||
|
dir = wxTOP;
|
||||||
|
else if ( dirstr == "wxBOTTOM" )
|
||||||
|
dir = wxBOTTOM;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ReportError
|
||||||
|
(
|
||||||
|
GetParamNode(param),
|
||||||
|
wxString::Format
|
||||||
|
(
|
||||||
|
"Invalid direction \"%s\": must be one of "
|
||||||
|
"wxLEFT|wxRIGHT|wxTOP|wxBOTTOM.",
|
||||||
|
dirstr
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
dir = dirDefault;
|
||||||
|
}
|
||||||
|
|
||||||
|
return dir;
|
||||||
|
}
|
||||||
|
|
||||||
// Get system font index using indexname
|
// Get system font index using indexname
|
||||||
static wxFont GetSystemFont(const wxString& name)
|
static wxFont GetSystemFont(const wxString& name)
|
||||||
|
Reference in New Issue
Block a user