Changed the wxPlatform syntax as per Vadim's suggestions
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38755 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -105,8 +105,8 @@ WXDLLIMPEXP_BASE wxString wxGetDataDir();
|
|||||||
* Class to make it easier to specify platform-dependent values
|
* Class to make it easier to specify platform-dependent values
|
||||||
*
|
*
|
||||||
* Examples:
|
* Examples:
|
||||||
* long val = wxPlatform(3).Is(wxMac, 1).Is(wxGTK, 2).Is(stPDA, 5);
|
* long val = wxPlatform::If(wxMac, 1).ElseIf(wxGTK, 2).ElseIf(stPDA, 5).Else(3);
|
||||||
* wxString strVal = wxPlatform(wxT("Hello")).Is(wxMac, wxT("Mac")).Is(wxMSW, wxT("MSW"));
|
* wxString strVal = wxPlatform::If(wxMac, wxT("Mac")).ElseIf(wxMSW, wxT("MSW")).Else(wxT("Other"));
|
||||||
*
|
*
|
||||||
* A custom platform symbol:
|
* A custom platform symbol:
|
||||||
*
|
*
|
||||||
@@ -115,37 +115,47 @@ WXDLLIMPEXP_BASE wxString wxGetDataDir();
|
|||||||
* wxPlatform::AddPlatform(stPDA);
|
* wxPlatform::AddPlatform(stPDA);
|
||||||
* #endif
|
* #endif
|
||||||
*
|
*
|
||||||
* long windowStyle = wxCAPTION | (long) wxPlatform().IsNot(stPDA, wxRESIZE_BORDER);
|
* long windowStyle = wxCAPTION | (long) wxPlatform::IfNot(stPDA, wxRESIZE_BORDER);
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class WXDLLIMPEXP_BASE wxPlatform
|
class WXDLLIMPEXP_BASE wxPlatform
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxPlatform() { m_longValue = 0; m_doubleValue = 0.0; }
|
wxPlatform() { Init(); }
|
||||||
|
wxPlatform(const wxPlatform& platform) { Copy(platform); }
|
||||||
|
void operator = (const wxPlatform& platform) { Copy(platform); }
|
||||||
|
void Copy(const wxPlatform& platform);
|
||||||
|
void Init() { m_longValue = 0; m_doubleValue = 0.0; }
|
||||||
|
|
||||||
// Specify an optional default value
|
// Specify an optional default value
|
||||||
wxPlatform(long defValue) { m_longValue = defValue; m_doubleValue = 0.0; }
|
wxPlatform(long defValue) { m_longValue = defValue; m_doubleValue = 0.0; }
|
||||||
wxPlatform(const wxString& defValue) { m_stringValue = defValue; m_longValue = 0; m_doubleValue = 0.0; }
|
wxPlatform(const wxString& defValue) { m_stringValue = defValue; m_longValue = 0; m_doubleValue = 0.0; }
|
||||||
wxPlatform(double defValue) { m_longValue = 0; m_doubleValue = defValue; }
|
wxPlatform(double defValue) { m_longValue = 0; m_doubleValue = defValue; }
|
||||||
|
|
||||||
wxPlatform& Is(int platform, long value);
|
static wxPlatform If(int platform, long value);
|
||||||
wxPlatform& IsNot(int platform, long value);
|
static wxPlatform IfNot(int platform, long value);
|
||||||
|
wxPlatform& ElseIf(int platform, long value);
|
||||||
|
wxPlatform& ElseIfNot(int platform, long value);
|
||||||
|
wxPlatform& Else(long value);
|
||||||
|
|
||||||
wxPlatform& Is(int platform, int value) { return Is(platform, (long) value); }
|
static wxPlatform If(int platform, int value);
|
||||||
wxPlatform& IsNot(int platform, int value) { return IsNot(platform, (long) value); }
|
static wxPlatform IfNot(int platform, int value) { return IfNot(platform, (long)value); }
|
||||||
|
wxPlatform& ElseIf(int platform, int value) { return ElseIf(platform, (long) value); }
|
||||||
|
wxPlatform& ElseIfNot(int platform, int value) { return ElseIfNot(platform, (long) value); }
|
||||||
|
wxPlatform& Else(int value) { return Else((long) value); }
|
||||||
|
|
||||||
wxPlatform& Is(int platform, const wxString& value);
|
static wxPlatform If(int platform, double value);
|
||||||
wxPlatform& IsNot(int platform, const wxString& value);
|
static wxPlatform IfNot(int platform, double value);
|
||||||
|
wxPlatform& ElseIf(int platform, double value);
|
||||||
|
wxPlatform& ElseIfNot(int platform, double value);
|
||||||
|
wxPlatform& Else(double value);
|
||||||
|
|
||||||
wxPlatform& Is(int platform, double value);
|
static wxPlatform If(int platform, const wxString& value);
|
||||||
wxPlatform& IsNot(int platform, double value);
|
static wxPlatform IfNot(int platform, const wxString& value);
|
||||||
|
wxPlatform& ElseIf(int platform, const wxString& value);
|
||||||
// This should be specified first to set the default value, or simply
|
wxPlatform& ElseIfNot(int platform, const wxString& value);
|
||||||
// pass the value to the constructor
|
wxPlatform& Else(const wxString& value);
|
||||||
wxPlatform& Default(long value);
|
|
||||||
wxPlatform& Default(const wxString& value);
|
|
||||||
wxPlatform& Default(double value);
|
|
||||||
|
|
||||||
long GetInteger() const { return m_longValue; }
|
long GetInteger() const { return m_longValue; }
|
||||||
const wxString& GetString() const { return m_stringValue; }
|
const wxString& GetString() const { return m_stringValue; }
|
||||||
@@ -158,7 +168,7 @@ public:
|
|||||||
operator const wxChar*() const { return (const wxChar*) GetString(); }
|
operator const wxChar*() const { return (const wxChar*) GetString(); }
|
||||||
|
|
||||||
static void AddPlatform(int platform);
|
static void AddPlatform(int platform);
|
||||||
static bool PlatformIs(int platform);
|
static bool Is(int platform);
|
||||||
static void ClearPlatforms();
|
static void ClearPlatforms();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -169,7 +179,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Function for testing current platform
|
/// Function for testing current platform
|
||||||
inline bool wxPlatformIs(int platform) { return wxPlatform::PlatformIs(platform); }
|
inline bool wxPlatformIs(int platform) { return wxPlatform::Is(platform); }
|
||||||
|
|
||||||
#if wxUSE_GUI
|
#if wxUSE_GUI
|
||||||
|
|
||||||
|
@@ -1460,7 +1460,7 @@ SettingsDialog::SettingsDialog(wxWindow* win, int dialogType)
|
|||||||
m_imageList = NULL;
|
m_imageList = NULL;
|
||||||
|
|
||||||
Create(win, wxID_ANY, _("Preferences"), wxDefaultPosition, wxDefaultSize,
|
Create(win, wxID_ANY, _("Preferences"), wxDefaultPosition, wxDefaultSize,
|
||||||
wxDEFAULT_DIALOG_STYLE| (int)wxPlatform().IsNot(wxWinCE, resizeBorder)
|
wxDEFAULT_DIALOG_STYLE| (int)wxPlatform::IfNot(wxWinCE, resizeBorder)
|
||||||
/*
|
/*
|
||||||
#ifndef __WXWINCE__
|
#ifndef __WXWINCE__
|
||||||
|resizeBorder
|
|resizeBorder
|
||||||
@@ -1470,7 +1470,7 @@ SettingsDialog::SettingsDialog(wxWindow* win, int dialogType)
|
|||||||
|
|
||||||
// If using a toolbook, also follow Mac style and don't create buttons
|
// If using a toolbook, also follow Mac style and don't create buttons
|
||||||
if (!useToolBook)
|
if (!useToolBook)
|
||||||
CreateButtons(wxOK|wxCANCEL| (int)wxPlatform().IsNot(wxWinPocketPC, wxHELP)
|
CreateButtons(wxOK|wxCANCEL| (int)wxPlatform::IfNot(wxWinPocketPC, wxHELP)
|
||||||
/*
|
/*
|
||||||
#ifndef __POCKETPC__
|
#ifndef __POCKETPC__
|
||||||
|wxHELP
|
|wxHELP
|
||||||
|
@@ -309,61 +309,116 @@ int wxGetOsVersion(int *verMaj, int *verMin)
|
|||||||
|
|
||||||
wxArrayInt* wxPlatform::sm_customPlatforms = NULL;
|
wxArrayInt* wxPlatform::sm_customPlatforms = NULL;
|
||||||
|
|
||||||
wxPlatform& wxPlatform::Is(int platform, long value)
|
void wxPlatform::Copy(const wxPlatform& platform)
|
||||||
{
|
{
|
||||||
if (wxPlatformIs(platform))
|
m_longValue = platform.m_longValue;
|
||||||
|
m_doubleValue = platform.m_doubleValue;
|
||||||
|
m_stringValue = platform.m_stringValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxPlatform wxPlatform::If(int platform, long value)
|
||||||
|
{
|
||||||
|
if (Is(platform))
|
||||||
|
return wxPlatform(value);
|
||||||
|
else
|
||||||
|
return wxPlatform();
|
||||||
|
}
|
||||||
|
|
||||||
|
wxPlatform wxPlatform::IfNot(int platform, long value)
|
||||||
|
{
|
||||||
|
if (!Is(platform))
|
||||||
|
return wxPlatform(value);
|
||||||
|
else
|
||||||
|
return wxPlatform();
|
||||||
|
}
|
||||||
|
|
||||||
|
wxPlatform& wxPlatform::ElseIf(int platform, long value)
|
||||||
|
{
|
||||||
|
if (Is(platform))
|
||||||
m_longValue = value;
|
m_longValue = value;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPlatform& wxPlatform::IsNot(int platform, long value)
|
wxPlatform& wxPlatform::ElseIfNot(int platform, long value)
|
||||||
{
|
{
|
||||||
if (!wxPlatformIs(platform))
|
if (!Is(platform))
|
||||||
m_longValue = value;
|
m_longValue = value;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPlatform& wxPlatform::Is(int platform, double value)
|
wxPlatform wxPlatform::If(int platform, double value)
|
||||||
{
|
{
|
||||||
if (wxPlatformIs(platform))
|
if (Is(platform))
|
||||||
|
return wxPlatform(value);
|
||||||
|
else
|
||||||
|
return wxPlatform();
|
||||||
|
}
|
||||||
|
|
||||||
|
wxPlatform wxPlatform::IfNot(int platform, double value)
|
||||||
|
{
|
||||||
|
if (!Is(platform))
|
||||||
|
return wxPlatform(value);
|
||||||
|
else
|
||||||
|
return wxPlatform();
|
||||||
|
}
|
||||||
|
|
||||||
|
wxPlatform& wxPlatform::ElseIf(int platform, double value)
|
||||||
|
{
|
||||||
|
if (Is(platform))
|
||||||
m_doubleValue = value;
|
m_doubleValue = value;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPlatform& wxPlatform::IsNot(int platform, double value)
|
wxPlatform& wxPlatform::ElseIfNot(int platform, double value)
|
||||||
{
|
{
|
||||||
if (!wxPlatformIs(platform))
|
if (!Is(platform))
|
||||||
m_doubleValue = value;
|
m_doubleValue = value;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPlatform& wxPlatform::Is(int platform, const wxString& value)
|
wxPlatform wxPlatform::If(int platform, const wxString& value)
|
||||||
{
|
{
|
||||||
if (wxPlatformIs(platform))
|
if (Is(platform))
|
||||||
|
return wxPlatform(value);
|
||||||
|
else
|
||||||
|
return wxPlatform();
|
||||||
|
}
|
||||||
|
|
||||||
|
wxPlatform wxPlatform::IfNot(int platform, const wxString& value)
|
||||||
|
{
|
||||||
|
if (!Is(platform))
|
||||||
|
return wxPlatform(value);
|
||||||
|
else
|
||||||
|
return wxPlatform();
|
||||||
|
}
|
||||||
|
|
||||||
|
wxPlatform& wxPlatform::ElseIf(int platform, const wxString& value)
|
||||||
|
{
|
||||||
|
if (Is(platform))
|
||||||
m_stringValue = value;
|
m_stringValue = value;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPlatform& wxPlatform::IsNot(int platform, const wxString& value)
|
wxPlatform& wxPlatform::ElseIfNot(int platform, const wxString& value)
|
||||||
{
|
{
|
||||||
if (!wxPlatformIs(platform))
|
if (!Is(platform))
|
||||||
m_stringValue = value;
|
m_stringValue = value;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPlatform& wxPlatform::Default(long value)
|
wxPlatform& wxPlatform::Else(long value)
|
||||||
{
|
{
|
||||||
m_longValue = value;
|
m_longValue = value;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPlatform& wxPlatform::Default(double value)
|
wxPlatform& wxPlatform::Else(double value)
|
||||||
{
|
{
|
||||||
m_doubleValue = value;
|
m_doubleValue = value;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPlatform& wxPlatform::Default(const wxString& value)
|
wxPlatform& wxPlatform::Else(const wxString& value)
|
||||||
{
|
{
|
||||||
m_stringValue = value;
|
m_stringValue = value;
|
||||||
return *this;
|
return *this;
|
||||||
@@ -384,7 +439,7 @@ void wxPlatform::ClearPlatforms()
|
|||||||
|
|
||||||
/// Function for testing current platform
|
/// Function for testing current platform
|
||||||
|
|
||||||
bool wxPlatform::PlatformIs(int platform)
|
bool wxPlatform::Is(int platform)
|
||||||
{
|
{
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
if (platform == wxMSW)
|
if (platform == wxMSW)
|
||||||
|
Reference in New Issue
Block a user