*/
#include <config.h>
+
#include "ButtonPolicies.h"
#include "debug.h"
+using std::endl;
-// Helper function
-inline void nextState(ButtonPolicy::State & state,
+/// Helper function
+static inline
+void nextState(ButtonPolicy::State & state,
ButtonPolicy::SMInput in,
- ButtonPolicy::StateMachine s_m,
+ ButtonPolicy::StateMachine const & s_m,
char const * function_name = "nextState")
{
ButtonPolicy::State tmp = s_m[state][in];
<< in
<< " from state "
<< state
- << std::endl;
+ << endl;
}
}
PreferencesPolicy::PreferencesPolicy()
: state_(INITIAL),
- outputs_(APPLIED+1,
- static_cast<int const &>(OKAY | APPLY | CANCEL | UNDO_ALL)),
- state_machine_(APPLIED+1,
- StateArray(SMI_TOTAL,
- static_cast<State const &>(BOGUS)))
+ outputs_(APPLIED + 1, ButtonPolicy::ALL_BUTTONS),
+ state_machine_(APPLIED + 1,
+ StateArray(int(SMI_TOTAL), ButtonPolicy::BOGUS))
{
// Build the state output map
outputs_[INITIAL] = CLOSE;
void PreferencesPolicy::input(SMInput input)
{
+ //lyxerr << "PreferencesPolicy::input" << endl;
// CANCEL and HIDE always take us to INITIAL for all cases.
// Note that I didn't put that special case in the helper function
// because it doesn't belong there. Some other
}
+/*-------------------------------OkViewPolicy------------------------------*/
+
+
+OkViewPolicy::OkViewPolicy()
+ : state_(INITIAL),
+ outputs_(INVALID + 1, ButtonPolicy::ALL_BUTTONS),
+ state_machine_(INVALID + 1,
+ StateArray(int(SMI_TOTAL), ButtonPolicy::BOGUS))
+{
+}
+
+
+
+void OkViewPolicy::input(SMInput)
+{
+ state_ = VALID;
+}
+
+
/*-------------------------------OkCancelPolicy------------------------------*/
OkCancelPolicy::OkCancelPolicy()
: state_(INITIAL),
- outputs_(INVALID+1,
- static_cast<int const &>(OKAY | APPLY | CANCEL | UNDO_ALL)),
- state_machine_(INVALID+1,
- StateArray(SMI_TOTAL,
- static_cast<State const &>(BOGUS)))
+ outputs_(INVALID + 1, ButtonPolicy::ALL_BUTTONS),
+ state_machine_(INVALID + 1,
+ StateArray(int(SMI_TOTAL), ButtonPolicy::BOGUS))
{
// Build the state output map
outputs_[INITIAL] = CLOSE;
void OkCancelPolicy::input(SMInput input)
{
+ //lyxerr << "OkCancelPolicy::input" << endl;
+
// CANCEL and HIDE always take us to INITIAL for all cases
if (SMI_CANCEL == input
|| SMI_HIDE == input) {
OkCancelReadOnlyPolicy::OkCancelReadOnlyPolicy()
: state_(INITIAL),
- outputs_(RO_INVALID+1,
- static_cast<int const &>(OKAY | APPLY | CANCEL | UNDO_ALL)),
- state_machine_(RO_INVALID+1,
- StateArray(SMI_TOTAL,
- static_cast<State const &>(BOGUS)))
+ outputs_(RO_INVALID + 1, ButtonPolicy::ALL_BUTTONS),
+ state_machine_(RO_INVALID + 1,
+ StateArray(int(SMI_TOTAL), ButtonPolicy::BOGUS))
{
// Build the state output map
outputs_[INITIAL] = CLOSE;
void OkCancelReadOnlyPolicy::input(SMInput input)
{
+ //lyxerr << "OkCancelReadOnlyPolicy::input" << endl;
+
// CANCEL and HIDE always take us to INITIAL for all cases
if (SMI_CANCEL == input
|| SMI_HIDE == input) {
NoRepeatedApplyReadOnlyPolicy::NoRepeatedApplyReadOnlyPolicy()
: state_(INITIAL),
- outputs_(RO_INVALID+1,
- static_cast<int const &>(OKAY | APPLY | CANCEL | UNDO_ALL)),
- state_machine_(RO_INVALID+1,
- StateArray(SMI_TOTAL,
- static_cast<State const &>(BOGUS)))
+ outputs_(RO_INVALID + 1, ButtonPolicy::ALL_BUTTONS),
+ state_machine_(RO_INVALID + 1,
+ StateArray(int(SMI_TOTAL), ButtonPolicy::BOGUS))
{
// Build the state output map
outputs_[INITIAL] = CLOSE;
void NoRepeatedApplyReadOnlyPolicy::input(SMInput input)
{
+ //lyxerr << "NoReapeatedApplyReadOnlyPolicy::input" << endl;
+
// CANCEL and HIDE always take us to INITIAL for all cases
if (SMI_CANCEL == input
|| SMI_HIDE == input) {
OkApplyCancelReadOnlyPolicy::OkApplyCancelReadOnlyPolicy()
: state_(INITIAL),
- outputs_(RO_APPLIED+1,
- static_cast<int const &>(OKAY | APPLY | CANCEL | UNDO_ALL)),
- state_machine_(RO_APPLIED+1,
- StateArray(SMI_TOTAL,
- static_cast<State const &>(BOGUS)))
+ outputs_(RO_APPLIED + 1, ButtonPolicy::ALL_BUTTONS),
+ state_machine_(RO_APPLIED + 1,
+ StateArray(int(SMI_TOTAL), ButtonPolicy::BOGUS))
{
// Build the state output map
outputs_[INITIAL] = CLOSE;
void OkApplyCancelReadOnlyPolicy::input(SMInput input)
{
+ //lyxerr << "OkApplyCancelReadOnlyPolicy::input" << endl;
+
// CANCEL and HIDE always take us to INITIAL for all cases
if (SMI_CANCEL == input
|| SMI_HIDE == input) {
OkApplyCancelPolicy::OkApplyCancelPolicy()
: state_(INITIAL),
- outputs_(APPLIED+1,
- static_cast<int const &>(OKAY | APPLY | CANCEL | UNDO_ALL)),
- state_machine_(APPLIED+1,
- StateArray(SMI_TOTAL,
- static_cast<State const &>(BOGUS)))
+ outputs_(APPLIED + 1, ButtonPolicy::ALL_BUTTONS),
+ state_machine_(APPLIED + 1,
+ StateArray(int(SMI_TOTAL), ButtonPolicy::BOGUS))
{
// Build the state output map
outputs_[INITIAL] = CLOSE;
void OkApplyCancelPolicy::input(SMInput input)
{
+ //lyxerr << "OkApplyCancelPolicy::input" << endl;
+
// CANCEL and HIDE always take us to INITIAL for all cases
if (SMI_CANCEL == input
|| SMI_HIDE == input) {
NoRepeatedApplyPolicy::NoRepeatedApplyPolicy()
: state_(INITIAL),
- outputs_(INVALID+1,
- static_cast<int const &>(OKAY | APPLY | CANCEL | UNDO_ALL)),
- state_machine_(INVALID+1,
- StateArray(SMI_TOTAL,
- static_cast<State const &>(BOGUS)))
+ outputs_(INVALID + 1, ButtonPolicy::ALL_BUTTONS),
+ state_machine_(INVALID + 1,
+ StateArray(int(SMI_TOTAL), ButtonPolicy::BOGUS))
{
// Build the state output map
outputs_[INITIAL] = CLOSE;
void NoRepeatedApplyPolicy::input(SMInput input)
{
+ //lyxerr << "NoRepeatedApplyPolicy::input" << endl;
+
// CANCEL and HIDE always take us to INITIAL for all cases
if (SMI_CANCEL == input
|| SMI_HIDE == input) {