Fixes for wxUSE_SPIN... == 0.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30743 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Włodzimierz Skiba
2004-11-23 20:08:56 +00:00
parent 44d60c0b26
commit 0e871ad039
5 changed files with 59 additions and 20 deletions

View File

@@ -1273,7 +1273,7 @@
#endif /* wxUSE_HELP */
#if wxUSE_WXHTML_HELP
# if !wxUSE_HELP || !wxUSE_HTML || !wxUSE_COMBOBOX || !wxUSE_NOTEBOOK
# if !wxUSE_HELP || !wxUSE_HTML || !wxUSE_COMBOBOX || !wxUSE_NOTEBOOK || !wxUSE_SPINCTRL
# ifdef wxABORT_ON_CONFIG_ERROR
# error "Built in help controller can't be compiled"
# else
@@ -1285,6 +1285,8 @@
# define wxUSE_COMBOBOX 1
# undef wxUSE_NOTEBOOK
# define wxUSE_NOTEBOOK 1
# undef wxUSE_SPINCTRL
# define wxUSE_SPINCTRL 1
# endif
# endif
#endif /* wxUSE_WXHTML_HELP */

View File

@@ -79,7 +79,9 @@ class WXDLLIMPEXP_ADV wxGridSelection;
class WXDLLEXPORT wxCheckBox;
class WXDLLEXPORT wxComboBox;
class WXDLLEXPORT wxTextCtrl;
#if wxUSE_SPINCTRL
class WXDLLEXPORT wxSpinCtrl;
#endif
// ----------------------------------------------------------------------------
// macros
@@ -460,10 +462,19 @@ public:
virtual wxString GetValue() const;
protected:
#if wxUSE_SPINCTRL
wxSpinCtrl *Spin() const { return (wxSpinCtrl *)m_control; }
#endif
// if HasRange(), we use wxSpinCtrl - otherwise wxTextCtrl
bool HasRange() const { return m_min != m_max; }
bool HasRange() const
{
#if wxUSE_SPINCTRL
return m_min != m_max;
#else
return false;
#endif
}
// string representation of m_valueOld
wxString GetString() const

View File

@@ -96,6 +96,17 @@
#define wxUSE_CHECKLISTBOX 0
#endif
#if wxUSE_SPINCTRL
# if !wxUSE_SPINBTN
# ifdef wxABORT_ON_CONFIG_ERROR
# error "wxSpinCtrl requires wxSpinButton on MSW"
# else
# undef wxUSE_SPINBTN
# define wxUSE_SPINBTN 1
# endif
# endif
#endif
#if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
/* BC++ 4.0 can't compile JPEG library */
#undef wxUSE_LIBJPEG

View File

@@ -18,6 +18,8 @@
#include "wx/spinbutt.h" // the base class
#if wxUSE_SPINCTRL
#include "wx/dynarray.h"
class WXDLLEXPORT wxSpinCtrl;
@@ -116,6 +118,8 @@ private:
DECLARE_NO_COPY_CLASS(wxSpinCtrl)
};
#endif // wxUSE_SPINCTRL
#endif // _WX_MSW_SPINCTRL_H_

View File

@@ -802,6 +802,7 @@ void wxGridCellNumberEditor::Create(wxWindow* parent,
wxWindowID id,
wxEvtHandler* evtHandler)
{
#if wxUSE_SPINCTRL
if ( HasRange() )
{
// create a spin ctrl
@@ -813,6 +814,7 @@ void wxGridCellNumberEditor::Create(wxWindow* parent,
wxGridCellEditor::Create(parent, id, evtHandler);
}
else
#endif
{
// just a text control
wxGridCellTextEditor::Create(parent, id, evtHandler);
@@ -835,19 +837,21 @@ void wxGridCellNumberEditor::BeginEdit(int row, int col, wxGrid* grid)
{
m_valueOld = 0;
wxString sValue = table->GetValue(row, col);
if (! sValue.ToLong(&m_valueOld) && ! sValue.IsEmpty())
if (! sValue.ToLong(&m_valueOld) && ! sValue.empty())
{
wxFAIL_MSG( _T("this cell doesn't have numeric value") );
return;
}
}
#if wxUSE_SPINCTRL
if ( HasRange() )
{
Spin()->SetValue((int)m_valueOld);
Spin()->SetFocus();
}
else
#endif
{
DoBeginEdit(GetString());
}
@@ -860,6 +864,7 @@ bool wxGridCellNumberEditor::EndEdit(int row, int col,
long value = 0;
wxString text;
#if wxUSE_SPINCTRL
if ( HasRange() )
{
value = Spin()->GetValue();
@@ -868,9 +873,10 @@ bool wxGridCellNumberEditor::EndEdit(int row, int col,
text = wxString::Format(wxT("%ld"), value);
}
else
#endif
{
text = Text()->GetValue();
changed = (text.IsEmpty() || text.ToLong(&value)) && (value != m_valueOld);
changed = (text.empty() || text.ToLong(&value)) && (value != m_valueOld);
}
if ( changed )
@@ -886,11 +892,13 @@ bool wxGridCellNumberEditor::EndEdit(int row, int col,
void wxGridCellNumberEditor::Reset()
{
#if wxUSE_SPINCTRL
if ( HasRange() )
{
Spin()->SetValue((int)m_valueOld);
}
else
#endif
{
DoReset(GetString());
}
@@ -994,15 +1002,18 @@ wxString wxGridCellNumberEditor::GetValue() const
{
wxString s;
#if wxUSE_SPINCTRL
if( HasRange() )
{
long value = Spin()->GetValue();
s.Printf(wxT("%ld"), value);
}
else
#endif
{
s = Text()->GetValue();
}
return s;
}
@@ -1039,7 +1050,7 @@ void wxGridCellFloatEditor::BeginEdit(int row, int col, wxGrid* grid)
{
m_valueOld = 0.0;
wxString sValue = table->GetValue(row, col);
if (! sValue.ToDouble(&m_valueOld) && ! sValue.IsEmpty())
if (! sValue.ToDouble(&m_valueOld) && ! sValue.empty())
{
wxFAIL_MSG( _T("this cell doesn't have float value") );
return;
@@ -1055,7 +1066,7 @@ bool wxGridCellFloatEditor::EndEdit(int row, int col,
double value = 0.0;
wxString text(Text()->GetValue());
if ( (text.IsEmpty() || text.ToDouble(&value)) && (value != m_valueOld) )
if ( (text.empty() || text.ToDouble(&value)) && (value != m_valueOld) )
{
if (grid->GetTable()->CanSetValueAs(row, col, wxGRID_VALUE_FLOAT))
grid->GetTable()->SetValueAsDouble(row, col, value);