improve the spinbox and inputbox

improve the input check for spinbox
add a verifier to check user input for inputbox
This commit is contained in:
cnjinhao
2015-02-07 11:47:45 +08:00
parent e0a9a94a8b
commit 274155b1da
7 changed files with 174 additions and 129 deletions

View File

@@ -206,6 +206,9 @@ namespace nana
return _m_open(contents, true);
}
/// Sets a verifier to verify the user input.
void verify(std::function<bool(window)> verifier);
private:
void _m_fetch_args(std::vector<abstract_content*>&);
@@ -221,6 +224,7 @@ namespace nana
window owner_;
::nana::string description_;
::nana::string title_;
std::function<bool(window)> verifier_;
};
}//end namespace nana

View File

@@ -69,6 +69,8 @@ namespace nana
/// "corrected" size that changes lines to fit the text into the specified width
nana::size measure(unsigned allowed_width_in_pixel) const;
static ::nana::size measure(::nana::paint::graphics&, const ::nana::string&, unsigned allowed_width_in_pixel, bool format_enabled, align h_align, align_v v_align);
label& text_align(align horizontal_align, align_v vertical_align= align_v::top);
private:
//Overrides widget's virtual function

View File

@@ -93,8 +93,8 @@ namespace nana
void range(double begin, double last, double step);
/// Sets the string spin values.
void range(std::initializer_list<std::string> steps_utf8);
void range(std::initializer_list<std::wstring> steps);
void range(std::initializer_list<std::string> values_utf8);
void range(std::initializer_list<std::wstring> values);
/// Gets the spined value
::nana::string value() const;
@@ -102,22 +102,9 @@ namespace nana
int to_int() const;
double to_double() const;
/// Sets a predicator that determines whether accepts the current user input.
/// @param pred Predicator to determines the input.
void set_accept(std::function<bool(::nana::char_t)> pred);
/// Sets the spinbox that only accepts integer input.
void set_accept_integer();
/// Sets the spinbox that only accepts real number input.
void set_accept_real();
/// Removes the accept excluding predicate accept.
void remove_accept();
/// Sets the qualifications
void qualify(std::wstring prefix, std::wstring suffix);
void qualify(const std::string & prefix_utf8, const std::string& suffix_utf8);
/// Sets the modifiers
void modifier(std::wstring prefix, std::wstring suffix);
void modifier(const std::string & prefix_utf8, const std::string& suffix_utf8);
private:
::nana::string _m_caption() const;
void _m_caption(::nana::string&&);