[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lmi] Input-sequence editor testing
From: |
Vaclav Slavik |
Subject: |
Re: [lmi] Input-sequence editor testing |
Date: |
Sun, 01 Aug 2010 19:32:45 +0200 |
Hi,
On Sun, 2010-07-04 at 22:01 +0000, Greg Chicares wrote:
> * Use default keyword in new keyword-only controls
>
> alt-F N I
> "Individual mode"
> "..."
> choose "until retirement"
> Second row, first column: no mode selected. The best choice would be
> the 'default_keyword' argument of realize_sequence_string().
Here's the patch:
diff --git a/datum_sequence.cpp b/datum_sequence.cpp
index 5c62cc0..4523ad4 100644
--- a/datum_sequence.cpp
+++ b/datum_sequence.cpp
@@ -89,6 +89,14 @@ bool datum_sequence::keyword_values_are_allowable() const
return false;
}
+/// Return default keyword in current context.
+///
+/// Return empty string if there's no default keyword.
+std::string const datum_sequence::default_keyword() const
+{
+ return std::string();
+}
+
/// Ascertain which keywords are allowed in the current context.
///
/// The return value is a map: keyword --> mc_enum string. Rationale:
@@ -206,6 +214,11 @@ mode_sequence& mode_sequence::operator=(std::string const&
s)
return *this;
}
+std::string const mode_sequence::default_keyword() const
+{
+ return "annual";
+}
+
std::map<std::string,std::string> const mode_sequence::allowed_keywords() const
{
LMI_ASSERT(!keyword_values_are_blocked());
diff --git a/datum_sequence.hpp b/datum_sequence.hpp
index 1bcdea7..667d0b2 100644
--- a/datum_sequence.hpp
+++ b/datum_sequence.hpp
@@ -80,6 +80,7 @@ class datum_sequence
//
virtual bool numeric_values_are_allowable() const;
virtual bool keyword_values_are_allowable() const;
+ virtual std::string const default_keyword() const;
virtual std::map<std::string,std::string> const allowed_keywords() const;
bool equals(datum_sequence const&) const;
@@ -148,6 +149,7 @@ class mode_sequence
virtual bool numeric_values_are_allowable() const {return false;}
virtual bool keyword_values_are_allowable() const {return true;}
+ virtual std::string const default_keyword() const;
virtual std::map<std::string,std::string> const allowed_keywords() const;
};
diff --git a/input_realization.cpp b/input_realization.cpp
index 2b8d847..29d30c4 100644
--- a/input_realization.cpp
+++ b/input_realization.cpp
@@ -607,7 +607,7 @@ std::string Input::RealizePaymentMode()
,PaymentModeRealized_
,PaymentMode
,PaymentMode.allowed_keywords()
- ,std::string("annual")
+ ,PaymentMode.default_keyword()
);
}
@@ -636,7 +636,7 @@ std::string Input::RealizeCorporationPaymentMode()
,CorporationPaymentModeRealized_
,CorporationPaymentMode
,CorporationPaymentMode.allowed_keywords()
- ,std::string("annual")
+ ,CorporationPaymentMode.default_keyword()
);
}
diff --git a/input_sequence_entry.cpp b/input_sequence_entry.cpp
index 8b93e6d..e17ae64 100644
--- a/input_sequence_entry.cpp
+++ b/input_sequence_entry.cpp
@@ -179,10 +179,14 @@ class InputSequenceEditor
public:
InputSequenceEditor(wxWindow* parent, wxString const& title, Input const&
input);
- void set_keywords(std::vector<std::string> const& keywords, bool only)
+ void set_keywords
+ (std::vector<std::string> const& keywords
+ ,bool only
+ ,std::string const& default_keyword)
{
keywords_ = keywords;
keywords_only_ = only;
+ default_keyword_ = default_keyword;
}
void sequence(InputSequence const& s);
@@ -264,6 +268,7 @@ class InputSequenceEditor
Input const& input_;
std::vector<std::string> keywords_;
bool keywords_only_;
+ std::string default_keyword_;
int rows_count_;
wxFlexGridSizer* sizer_;
@@ -500,6 +505,11 @@ void InputSequenceEditor::insert_row(int new_row)
std::copy(keywords_.begin(), keywords_.end(), std::back_inserter(kw));
combo->Append(kw);
+ if(keywords_only_ && !default_keyword_.empty())
+ {
+ combo->SetValue(default_keyword_.c_str());
+ }
+
if(!keywords_only_)
{
combo->AutoComplete(kw);
@@ -1075,7 +1085,7 @@ void InputSequenceEntry::UponOpenEditor(wxCommandEvent&)
&& !ds.numeric_values_are_allowable()
;
LMI_ASSERT(!(keywords_only && keywords.empty()));
- editor.set_keywords(keywords, keywords_only);
+ editor.set_keywords(keywords, keywords_only, ds.default_keyword());
InputSequence sequence
(sequence_string
Regards,
Vaclav
- Re: [lmi] Input-sequence editor testing,
Vaclav Slavik <=