Rename wxSpinCtrl helper functions

Put them in wxSpinCtrlImpl namespace and remove "wxSpinCtrl" prefix from
the function names themselves, this was ugly.

No real changes.
This commit is contained in:
Vadim Zeitlin
2019-11-13 02:51:00 +01:00
parent 4444694043
commit eb3d8395c2
6 changed files with 17 additions and 16 deletions

View File

@@ -10,18 +10,18 @@
#ifndef _WX_PRIVATE_SPINCTRL_H_ #ifndef _WX_PRIVATE_SPINCTRL_H_
#define _WX_PRIVATE_SPINCTRL_H_ #define _WX_PRIVATE_SPINCTRL_H_
namespace wxPrivate namespace wxSpinCtrlImpl
{ {
// This is an internal helper function currently used by all ports: return the // This is an internal helper function currently used by all ports: return the
// string containing hexadecimal representation of the given number. // string containing hexadecimal representation of the given number.
extern wxString wxSpinCtrlFormatAsHex(long val, long maxVal); extern wxString FormatAsHex(long val, long maxVal);
// The helper function to determine the best size for the given control. // The helper function to determine the best size for the given control.
// We can't implement this function in the wxSpinCtrlBase because MSW implementation // We can't implement this function in the wxSpinCtrlBase because MSW implementation
// of wxSpinCtrl is derived from wxSpinButton but uses the same algorithm. // of wxSpinCtrl is derived from wxSpinButton but uses the same algorithm.
extern wxSize wxSpinCtrlGetBestSize(const wxControl* spin, int minVal, int maxVal, int base); extern wxSize GetBestSize(const wxControl* spin, int minVal, int maxVal, int base);
} // namespace wxPrivate } // namespace wxSpinCtrlImpl
#endif // _WX_PRIVATE_SPINCTRL_H_ #endif // _WX_PRIVATE_SPINCTRL_H_

View File

@@ -104,7 +104,9 @@ wxCONSTRUCTOR_6( wxSpinCtrl, wxWindow*, Parent, wxWindowID, Id, \
wxSize, Size, long, WindowStyle ) wxSize, Size, long, WindowStyle )
wxString wxPrivate::wxSpinCtrlFormatAsHex(long val, long maxVal) using namespace wxSpinCtrlImpl;
wxString wxSpinCtrlImpl::FormatAsHex(long val, long maxVal)
{ {
// We format the value like this is for compatibility with (native // We format the value like this is for compatibility with (native
// behaviour of) wxMSW // behaviour of) wxMSW
@@ -117,14 +119,14 @@ wxString wxPrivate::wxSpinCtrlFormatAsHex(long val, long maxVal)
return text; return text;
} }
wxSize wxPrivate::wxSpinCtrlGetBestSize(const wxControl* spin, wxSize wxSpinCtrlImpl::GetBestSize(const wxControl* spin,
int minVal, int maxVal, int base) int minVal, int maxVal, int base)
{ {
const int lenMin = (base == 16 ? const int lenMin = (base == 16 ?
wxSpinCtrlFormatAsHex(minVal, maxVal) : FormatAsHex(minVal, maxVal) :
wxString::Format("%d", minVal)).length(); wxString::Format("%d", minVal)).length();
const int lenMax = (base == 16 ? const int lenMax = (base == 16 ?
wxSpinCtrlFormatAsHex(maxVal, maxVal) : FormatAsHex(maxVal, maxVal) :
wxString::Format("%d", maxVal)).length(); wxString::Format("%d", maxVal)).length();
const wxString largestString('8', wxMax(lenMin, lenMax)); const wxString largestString('8', wxMax(lenMin, lenMax));
return spin->GetSizeFromText(largestString); return spin->GetSizeFromText(largestString);

View File

@@ -656,8 +656,7 @@ wxString wxSpinCtrl::DoValueToText(double val)
switch ( GetBase() ) switch ( GetBase() )
{ {
case 16: case 16:
return wxPrivate::wxSpinCtrlFormatAsHex(static_cast<long>(val), return wxSpinCtrlImpl::FormatAsHex(static_cast<long>(val), GetMax());
GetMax());
default: default:
wxFAIL_MSG( wxS("Unsupported spin control base") ); wxFAIL_MSG( wxS("Unsupported spin control base") );

View File

@@ -359,7 +359,7 @@ wxSize wxSpinCtrlGTKBase::DoGetBestSize() const
{ {
const int minVal = static_cast<int>(DoGetMin()); const int minVal = static_cast<int>(DoGetMin());
const int maxVal = static_cast<int>(DoGetMax()); const int maxVal = static_cast<int>(DoGetMax());
return wxPrivate::wxSpinCtrlGetBestSize(this, minVal, maxVal, GetBase()); return wxSpinCtrlImpl::GetBestSize(this, minVal, maxVal, GetBase());
} }
wxSize wxSpinCtrlGTKBase::DoGetSizeFromTextSize(int xlen, int ylen) const wxSize wxSpinCtrlGTKBase::DoGetSizeFromTextSize(int xlen, int ylen) const
@@ -433,7 +433,7 @@ wx_gtk_spin_output(GtkSpinButton* spin, wxSpinCtrl* win)
gtk_entry_set_text gtk_entry_set_text
( (
GTK_ENTRY(spin), GTK_ENTRY(spin),
wxPrivate::wxSpinCtrlFormatAsHex(val, win->GetMax()).utf8_str() wxSpinCtrlImpl::FormatAsHex(val, win->GetMax()).utf8_str()
); );
return TRUE; return TRUE;

View File

@@ -71,7 +71,7 @@ wx_gtk_spin_output(GtkSpinButton* spin, wxSpinCtrl* win)
gtk_entry_set_text gtk_entry_set_text
( (
GTK_ENTRY(spin), GTK_ENTRY(spin),
wxPrivate::wxSpinCtrlFormatAsHex(val, win->GetMax()).utf8_str() wxSpinCtrlImpl::FormatAsHex(val, win->GetMax()).utf8_str()
); );
return TRUE; return TRUE;

View File

@@ -476,7 +476,7 @@ void wxSpinCtrl::SetValue(int val)
(text[1] != 'x' && text[1] != 'X')) ) (text[1] != 'x' && text[1] != 'X')) )
{ {
::SetWindowText(GetBuddyHwnd(), ::SetWindowText(GetBuddyHwnd(),
wxPrivate::wxSpinCtrlFormatAsHex(val, m_max).t_str()); wxSpinCtrlImpl::FormatAsHex(val, m_max).t_str());
} }
m_oldValue = GetValue(); m_oldValue = GetValue();
@@ -743,7 +743,7 @@ int wxSpinCtrl::GetOverlap() const
wxSize wxSpinCtrl::DoGetBestSize() const wxSize wxSpinCtrl::DoGetBestSize() const
{ {
return wxPrivate::wxSpinCtrlGetBestSize(this, GetMin(), GetMax(), GetBase()); return wxSpinCtrlImpl::GetBestSize(this, GetMin(), GetMax(), GetBase());
} }
wxSize wxSpinCtrl::DoGetSizeFromTextSize(int xlen, int ylen) const wxSize wxSpinCtrl::DoGetSizeFromTextSize(int xlen, int ylen) const