- // normally setting the value of the spin button is enough as it updates
- // its buddy control automatically ...
- if ( wxGetWindowText(m_hwndBuddy).empty() )
+ // Normally setting the value of the spin button is enough as it updates
+ // its buddy control automatically but in a couple of situations it doesn't
+ // do it, for whatever reason, do it explicitly then:
+ const wxString text = wxGetWindowText(m_hwndBuddy);
+
+ // First case is when the text control is empty and the value is 0: the
+ // spin button just leaves it empty in this case, while we want to show 0
+ // in it.
+ if ( text.empty() && !val )
+ {
+ ::SetWindowText(GetBuddyHwnd(), wxT("0"));
+ }
+
+ // Another one is when we're using hexadecimal base but the user input
+ // doesn't start with "0x" -- we prefer to show it to avoid ambiguity
+ // between decimal and hexadecimal.
+ if ( GetBase() == 16 &&
+ (text.length() < 3 || text[0] != '0' ||
+ (text[1] != 'x' && text[1] != 'X')) )