+++ /dev/null
-// -*- C++ -*-
-/* ButtonPolicies.C
- * Provides a state machine implementation of the various button policies
- * used by the dialogs.
- * Author: Allan Rae <rae@lyx.org>
- * This file is part of
- * ======================================================
- *
- * LyX, The Document Processor
- *
- * Copyright 1995 Matthias Ettrich
- * Copyright 1995-2000 The LyX Team.
- *
- * This file Copyright 2000
- * Allan Rae
- * ======================================================
- */
-
-#include <config.h>
-
-#include "ButtonPolicies.h"
-#include "debug.h"
-
-using std::endl;
-
-/// Helper function
-namespace {
-
-inline
-void nextState(ButtonPolicy::State & state,
- ButtonPolicy::SMInput in,
- ButtonPolicy::StateMachine const & s_m,
- char const * function_name = "nextState")
-{
- ButtonPolicy::State tmp = s_m[state][in];
- if (ButtonPolicy::BOGUS != tmp) {
- state = tmp;
- } else {
- lyxerr << function_name
- << ": No transition for input "
- << in
- << " from state "
- << state
- << endl;
- }
-}
-
-} // namespace anon
-
-
-/*-----------------------------PreferencesPolicy-----------------------------*/
-
-
-PreferencesPolicy::PreferencesPolicy()
- : state_(INITIAL),
- outputs_(APPLIED + 1, ButtonPolicy::ALL_BUTTONS),
- state_machine_(APPLIED + 1,
- StateArray(int(SMI_TOTAL), ButtonPolicy::BOGUS))
-{
- // Build the state output map
- outputs_[INITIAL] = CLOSE;
- outputs_[VALID] = UNDO_ALL | OKAY | APPLY | CANCEL;
- outputs_[INVALID] = UNDO_ALL | CANCEL;
- outputs_[APPLIED] = OKAY | CLOSE;
-
- // Build the state machine one state at a time
- // NOTE: Since CANCEL and HIDE always go to INITIAL they are
- // left out of the state machine and handled explicitly
- // in input(). This won't necessarily be true for all
- // policies though so I'll leave those two as distinct
- // inputs rather than merge them. For example, a dialog
- // that doesn't update it's input fields when reshown
- // after being hidden needs a policy where CANCEL and
- // HIDE are treated differently.
- //
- // State::INITIAL
- state_machine_[INITIAL][SMI_READ_ONLY] = INITIAL;
- state_machine_[INITIAL][SMI_READ_WRITE] = INITIAL;
- state_machine_[INITIAL][SMI_VALID] = VALID;
- state_machine_[INITIAL][SMI_INVALID] = INVALID;
- // State::VALID
- state_machine_[VALID][SMI_VALID] = VALID;
- state_machine_[VALID][SMI_READ_ONLY] = VALID;
- state_machine_[VALID][SMI_READ_WRITE] = VALID;
- state_machine_[VALID][SMI_INVALID] = INVALID;
- state_machine_[VALID][SMI_APPLY] = APPLIED;
- state_machine_[VALID][SMI_OKAY] = INITIAL;
- state_machine_[VALID][SMI_UNDO_ALL] = INITIAL;
- // State::INVALID
- state_machine_[INVALID][SMI_VALID] = VALID;
- state_machine_[INVALID][SMI_INVALID] = INVALID;
- state_machine_[INVALID][SMI_READ_ONLY] = INVALID;
- state_machine_[INVALID][SMI_READ_WRITE] = INVALID;
- state_machine_[INVALID][SMI_UNDO_ALL] = INITIAL;
- // State::APPLIED
- state_machine_[APPLIED][SMI_VALID] = VALID;
- state_machine_[APPLIED][SMI_INVALID] = INVALID;
- state_machine_[APPLIED][SMI_OKAY] = INITIAL;
- state_machine_[APPLIED][SMI_READ_ONLY] = APPLIED;
- state_machine_[APPLIED][SMI_READ_WRITE] = APPLIED;
-}
-
-
-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
- // This is probably optimising for the wrong case since it occurs as the
- // dialog will be hidden. It would have saved a little memory in the
- // state machine if I could have gotten map working. ARRae 20000813
- if (SMI_CANCEL == input
- || SMI_HIDE == input) {
- state_ = INITIAL;
- } else {
- nextState(state_,
- input,
- state_machine_,
- "PreferencesPolicy");
- }
-}
-
-
-/*-------------------------------OkCancelPolicy------------------------------*/
-
-
-OkCancelPolicy::OkCancelPolicy()
- : state_(INITIAL),
- outputs_(INVALID + 1, ButtonPolicy::ALL_BUTTONS),
- state_machine_(INVALID + 1,
- StateArray(int(SMI_TOTAL), ButtonPolicy::BOGUS))
-{
- // Build the state output map
- outputs_[INITIAL] = CLOSE;
- outputs_[VALID] = UNDO_ALL | OKAY | CANCEL;
- outputs_[INVALID] = UNDO_ALL | CANCEL;
-
- // Build the state machine one state at a time
- // NOTE: Since CANCEL and HIDE always go to INITIAL they are
- // left out of the state machine and handled explicitly
- // in input()
- //
- // State::INITIAL
- state_machine_[INITIAL][SMI_READ_ONLY] = INITIAL;
- state_machine_[INITIAL][SMI_READ_WRITE] = INITIAL;
- state_machine_[INITIAL][SMI_VALID] = VALID;
- state_machine_[INITIAL][SMI_INVALID] = INVALID;
- // State::VALID
- state_machine_[VALID][SMI_VALID] = VALID;
- state_machine_[VALID][SMI_READ_ONLY] = VALID;
- state_machine_[VALID][SMI_READ_WRITE] = VALID;
- state_machine_[VALID][SMI_INVALID] = INVALID;
- state_machine_[VALID][SMI_OKAY] = INITIAL;
- state_machine_[VALID][SMI_UNDO_ALL] = INITIAL;
- // State::INVALID
- state_machine_[INVALID][SMI_VALID] = VALID;
- state_machine_[INVALID][SMI_INVALID] = INVALID;
- state_machine_[INVALID][SMI_READ_ONLY] = INVALID;
- state_machine_[INVALID][SMI_READ_WRITE] = INVALID;
- state_machine_[INVALID][SMI_UNDO_ALL] = INITIAL;
-}
-
-
-
-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) {
- state_ = INITIAL;
- } else {
- nextState(state_, input, state_machine_, "OkCancelPolicy");
- }
-}
-
-
-/*---------------------------OkCancelReadOnlyPolicy-------------------------*/
-
-
-OkCancelReadOnlyPolicy::OkCancelReadOnlyPolicy()
- : state_(INITIAL),
- 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;
- outputs_[VALID] = UNDO_ALL | OKAY | CANCEL;
- outputs_[INVALID] = UNDO_ALL | CANCEL;
- outputs_[RO_INITIAL] = CLOSE;
- outputs_[RO_VALID] = UNDO_ALL | CANCEL;
- outputs_[RO_INVALID] = UNDO_ALL | CANCEL;
-
- // Build the state machine one state at a time
- // NOTE: Since CANCEL and HIDE always go to INITIAL they are
- // left out of the state machine and handled explicitly
- // in input()
- //
- // State::INITIAL
- state_machine_[INITIAL][SMI_READ_WRITE] = INITIAL;
- state_machine_[INITIAL][SMI_VALID] = VALID;
- state_machine_[INITIAL][SMI_INVALID] = INVALID;
- state_machine_[INITIAL][SMI_READ_ONLY] = RO_INITIAL;
- // State::VALID
- state_machine_[VALID][SMI_VALID] = VALID;
- state_machine_[VALID][SMI_READ_WRITE] = VALID;
- state_machine_[VALID][SMI_INVALID] = INVALID;
- state_machine_[VALID][SMI_OKAY] = INITIAL;
- state_machine_[VALID][SMI_UNDO_ALL] = INITIAL;
- state_machine_[VALID][SMI_READ_ONLY] = RO_VALID;
- // State::INVALID
- state_machine_[INVALID][SMI_INVALID] = INVALID;
- state_machine_[INVALID][SMI_READ_WRITE] = INVALID;
- state_machine_[INVALID][SMI_VALID] = VALID;
- state_machine_[INVALID][SMI_UNDO_ALL] = INITIAL;
- state_machine_[INVALID][SMI_READ_ONLY] = RO_INVALID;
- // State::RO_INITIAL
- state_machine_[RO_INITIAL][SMI_READ_ONLY] = RO_INITIAL;
- state_machine_[RO_INITIAL][SMI_VALID] = RO_VALID;
- state_machine_[RO_INITIAL][SMI_INVALID] = RO_INVALID;
- state_machine_[RO_INITIAL][SMI_READ_WRITE] = INITIAL;
- // State::RO_VALID
- state_machine_[RO_VALID][SMI_VALID] = RO_VALID;
- state_machine_[RO_VALID][SMI_READ_ONLY] = RO_VALID;
- state_machine_[RO_VALID][SMI_INVALID] = RO_INVALID;
- state_machine_[RO_VALID][SMI_READ_WRITE] = VALID;
- state_machine_[RO_VALID][SMI_UNDO_ALL] = RO_INITIAL;
- // State::RO_INVALID
- state_machine_[RO_INVALID][SMI_READ_ONLY] = RO_INVALID;
- state_machine_[RO_INVALID][SMI_INVALID] = RO_INVALID;
- state_machine_[RO_INVALID][SMI_VALID] = RO_VALID;
- state_machine_[RO_INVALID][SMI_READ_WRITE] = INVALID;
- state_machine_[RO_INVALID][SMI_UNDO_ALL] = RO_INITIAL;
-}
-
-
-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) {
- state_ = INITIAL;
- } else {
- nextState(state_,
- input,
- state_machine_,
- "OkCancelReadOnlyPolicy");
- }
-}
-
-
-/*--------------------------NoRepeatedApplyReadOnlyPolicy----------------------*/
-
-
-NoRepeatedApplyReadOnlyPolicy::NoRepeatedApplyReadOnlyPolicy()
- : state_(INITIAL),
- 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;
- outputs_[VALID] = UNDO_ALL | OKAY | APPLY | CANCEL;
- outputs_[INVALID] = UNDO_ALL | CANCEL;
- outputs_[RO_INITIAL] = CLOSE;
- outputs_[RO_VALID] = UNDO_ALL | CANCEL;
- outputs_[RO_INVALID] = UNDO_ALL | CANCEL;
-
- // Build the state machine one state at a time
- // NOTE: Since CANCEL and HIDE always go to INITIAL they are
- // left out of the state machine and handled explicitly
- // in input()
- //
- // State::INITIAL
- state_machine_[INITIAL][SMI_READ_WRITE] = INITIAL;
- state_machine_[INITIAL][SMI_VALID] = VALID;
- state_machine_[INITIAL][SMI_INVALID] = INVALID;
- state_machine_[INITIAL][SMI_READ_ONLY] = RO_INITIAL;
- // State::VALID
- state_machine_[VALID][SMI_VALID] = VALID;
- state_machine_[VALID][SMI_READ_WRITE] = VALID;
- state_machine_[VALID][SMI_INVALID] = INVALID;
- state_machine_[VALID][SMI_OKAY] = INITIAL;
- state_machine_[VALID][SMI_APPLY] = INITIAL;
- state_machine_[VALID][SMI_UNDO_ALL] = INITIAL;
- state_machine_[VALID][SMI_READ_ONLY] = RO_VALID;
- // State::INVALID
- state_machine_[INVALID][SMI_INVALID] = INVALID;
- state_machine_[INVALID][SMI_READ_WRITE] = INVALID;
- state_machine_[INVALID][SMI_VALID] = VALID;
- state_machine_[INVALID][SMI_UNDO_ALL] = INITIAL;
- state_machine_[INVALID][SMI_READ_ONLY] = RO_INVALID;
- // State::RO_INITIAL
- state_machine_[RO_INITIAL][SMI_READ_ONLY] = RO_INITIAL;
- state_machine_[RO_INITIAL][SMI_VALID] = RO_VALID;
- state_machine_[RO_INITIAL][SMI_INVALID] = RO_INVALID;
- state_machine_[RO_INITIAL][SMI_READ_WRITE] = INITIAL;
- // State::RO_VALID
- state_machine_[RO_VALID][SMI_VALID] = RO_VALID;
- state_machine_[RO_VALID][SMI_READ_ONLY] = RO_VALID;
- state_machine_[RO_VALID][SMI_INVALID] = RO_INVALID;
- state_machine_[RO_VALID][SMI_READ_WRITE] = VALID;
- state_machine_[RO_VALID][SMI_UNDO_ALL] = RO_INITIAL;
- // State::RO_INVALID
- state_machine_[RO_INVALID][SMI_INVALID] = RO_INVALID;
- state_machine_[RO_INVALID][SMI_READ_ONLY] = RO_INVALID;
- state_machine_[RO_INVALID][SMI_VALID] = RO_VALID;
- state_machine_[RO_INVALID][SMI_READ_WRITE] = INVALID;
- state_machine_[RO_INVALID][SMI_UNDO_ALL] = RO_INITIAL;
-}
-
-
-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) {
- state_ = INITIAL;
- } else {
- nextState(state_,
- input,
- state_machine_,
- "NoRepeatedApplyReadOnlyPolicy");
- }
-}
-
-
-/*--------------------------OkApplyCancelReadOnlyPolicy----------------------*/
-
-
-OkApplyCancelReadOnlyPolicy::OkApplyCancelReadOnlyPolicy()
- : state_(INITIAL),
- 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;
- outputs_[VALID] = UNDO_ALL | OKAY | APPLY | CANCEL;
- outputs_[INVALID] = UNDO_ALL | CANCEL;
- outputs_[APPLIED] = OKAY | APPLY | CLOSE;
- outputs_[RO_INITIAL] = CLOSE;
- outputs_[RO_VALID] = UNDO_ALL | CANCEL;
- outputs_[RO_INVALID] = UNDO_ALL | CANCEL;
- outputs_[RO_APPLIED] = CLOSE;
-
- // Build the state machine one state at a time
- // NOTE: Since CANCEL and HIDE always go to INITIAL they are
- // left out of the state machine and handled explicitly
- // in input()
- //
- // State::INITIAL
- state_machine_[INITIAL][SMI_READ_WRITE] = INITIAL;
- state_machine_[INITIAL][SMI_VALID] = VALID;
- state_machine_[INITIAL][SMI_INVALID] = INVALID;
- state_machine_[INITIAL][SMI_READ_ONLY] = RO_INITIAL;
- // State::VALID
- state_machine_[VALID][SMI_VALID] = VALID;
- state_machine_[VALID][SMI_READ_WRITE] = VALID;
- state_machine_[VALID][SMI_INVALID] = INVALID;
- state_machine_[VALID][SMI_OKAY] = INITIAL;
- state_machine_[VALID][SMI_UNDO_ALL] = INITIAL;
- state_machine_[VALID][SMI_APPLY] = APPLIED;
- state_machine_[VALID][SMI_READ_ONLY] = RO_VALID;
- // State::INVALID
- state_machine_[INVALID][SMI_INVALID] = INVALID;
- state_machine_[INVALID][SMI_READ_WRITE] = INVALID;
- state_machine_[INVALID][SMI_VALID] = VALID;
- state_machine_[INVALID][SMI_UNDO_ALL] = INITIAL;
- state_machine_[INVALID][SMI_READ_ONLY] = RO_INVALID;
- // State::APPLIED
- state_machine_[APPLIED][SMI_APPLY] = APPLIED;
- state_machine_[APPLIED][SMI_READ_WRITE] = APPLIED;
- state_machine_[APPLIED][SMI_VALID] = VALID;
- state_machine_[APPLIED][SMI_INVALID] = INVALID;
- state_machine_[APPLIED][SMI_OKAY] = INITIAL;
- state_machine_[APPLIED][SMI_READ_ONLY] = RO_APPLIED;
- // State::RO_INITIAL
- state_machine_[RO_INITIAL][SMI_READ_ONLY] = RO_INITIAL;
- state_machine_[RO_INITIAL][SMI_VALID] = RO_VALID;
- state_machine_[RO_INITIAL][SMI_INVALID] = RO_INVALID;
- state_machine_[RO_INITIAL][SMI_READ_WRITE] = INITIAL;
- // State::RO_VALID
- state_machine_[RO_VALID][SMI_VALID] = RO_VALID;
- state_machine_[RO_VALID][SMI_READ_ONLY] = RO_VALID;
- state_machine_[RO_VALID][SMI_INVALID] = RO_INVALID;
- state_machine_[RO_VALID][SMI_READ_WRITE] = VALID;
- state_machine_[RO_VALID][SMI_UNDO_ALL] = RO_INITIAL;
- // State::RO_INVALID
- state_machine_[RO_INVALID][SMI_INVALID] = RO_INVALID;
- state_machine_[RO_INVALID][SMI_READ_ONLY] = RO_INVALID;
- state_machine_[RO_INVALID][SMI_VALID] = RO_VALID;
- state_machine_[RO_INVALID][SMI_READ_WRITE] = INVALID;
- state_machine_[RO_INVALID][SMI_UNDO_ALL] = RO_INITIAL;
- // State::RO_APPLIED
- state_machine_[RO_APPLIED][SMI_READ_ONLY] = RO_APPLIED;
- state_machine_[RO_APPLIED][SMI_INVALID] = RO_INVALID;
- state_machine_[RO_APPLIED][SMI_VALID] = RO_VALID;
- state_machine_[RO_APPLIED][SMI_READ_WRITE] = APPLIED;
-}
-
-
-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) {
- state_ = INITIAL;
- } else {
- nextState(state_,
- input,
- state_machine_,
- "OkApplyCancelReadOnlyPolicy");
- }
-}
-
-
-/*--------------------------OkApplyCancelPolicy----------------------*/
-
-
-OkApplyCancelPolicy::OkApplyCancelPolicy()
- : state_(INITIAL),
- outputs_(APPLIED + 1, ButtonPolicy::ALL_BUTTONS),
- state_machine_(APPLIED + 1,
- StateArray(int(SMI_TOTAL), ButtonPolicy::BOGUS))
-{
- // Build the state output map
- outputs_[INITIAL] = CLOSE;
- outputs_[VALID] = UNDO_ALL | OKAY | APPLY | CANCEL;
- outputs_[INVALID] = UNDO_ALL | CANCEL;
- outputs_[APPLIED] = OKAY | APPLY | CLOSE;
-
- // Build the state machine one state at a time
- // NOTE: Since CANCEL and HIDE always go to INITIAL they are
- // left out of the state machine and handled explicitly
- // in input()
- //
- // State::INITIAL
- state_machine_[INITIAL][SMI_READ_ONLY] = INITIAL;
- state_machine_[INITIAL][SMI_READ_WRITE] = INITIAL;
- state_machine_[INITIAL][SMI_VALID] = VALID;
- state_machine_[INITIAL][SMI_INVALID] = INVALID;
- // State::VALID
- state_machine_[VALID][SMI_VALID] = VALID;
- state_machine_[VALID][SMI_READ_ONLY] = VALID;
- state_machine_[VALID][SMI_READ_WRITE] = VALID;
- state_machine_[VALID][SMI_INVALID] = INVALID;
- state_machine_[VALID][SMI_OKAY] = INITIAL;
- state_machine_[VALID][SMI_UNDO_ALL] = INITIAL;
- state_machine_[VALID][SMI_APPLY] = APPLIED;
- // State::INVALID
- state_machine_[INVALID][SMI_INVALID] = INVALID;
- state_machine_[INVALID][SMI_READ_ONLY] = INVALID;
- state_machine_[INVALID][SMI_READ_WRITE] = INVALID;
- state_machine_[INVALID][SMI_VALID] = VALID;
- state_machine_[INVALID][SMI_UNDO_ALL] = INITIAL;
- // State::APPLIED
- state_machine_[APPLIED][SMI_APPLY] = APPLIED;
- state_machine_[APPLIED][SMI_READ_ONLY] = APPLIED;
- state_machine_[APPLIED][SMI_READ_WRITE] = APPLIED;
- state_machine_[APPLIED][SMI_VALID] = VALID;
- state_machine_[APPLIED][SMI_INVALID] = INVALID;
- state_machine_[APPLIED][SMI_OKAY] = INITIAL;
-}
-
-
-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) {
- state_ = INITIAL;
- } else {
- nextState(state_,
- input,
- state_machine_,
- "OkApplyCancelPolicy");
- }
-}
-
-
-/*--------------------------NoRepeatedApplyPolicy----------------------*/
-
-
-NoRepeatedApplyPolicy::NoRepeatedApplyPolicy()
- : state_(INITIAL),
- outputs_(INVALID + 1, ButtonPolicy::ALL_BUTTONS),
- state_machine_(INVALID + 1,
- StateArray(int(SMI_TOTAL), ButtonPolicy::BOGUS))
-{
- // Build the state output map
- outputs_[INITIAL] = CLOSE;
- outputs_[VALID] = UNDO_ALL | OKAY | APPLY | CANCEL;
- outputs_[INVALID] = UNDO_ALL | CANCEL;
-
- // Build the state machine one state at a time
- // NOTE: Since CANCEL and HIDE always go to INITIAL they are
- // left out of the state machine and handled explicitly
- // in input()
- //
- // State::INITIAL
- state_machine_[INITIAL][SMI_READ_ONLY] = INITIAL;
- state_machine_[INITIAL][SMI_READ_WRITE] = INITIAL;
- state_machine_[INITIAL][SMI_VALID] = VALID;
- state_machine_[INITIAL][SMI_INVALID] = INVALID;
- // State::VALID
- state_machine_[VALID][SMI_VALID] = VALID;
- state_machine_[VALID][SMI_READ_ONLY] = VALID;
- state_machine_[VALID][SMI_READ_WRITE] = VALID;
- state_machine_[VALID][SMI_INVALID] = INVALID;
- state_machine_[VALID][SMI_OKAY] = INITIAL;
- state_machine_[VALID][SMI_APPLY] = INITIAL;
- state_machine_[VALID][SMI_UNDO_ALL] = INITIAL;
- // State::INVALID
- state_machine_[INVALID][SMI_INVALID] = INVALID;
- state_machine_[INVALID][SMI_READ_ONLY] = INVALID;
- state_machine_[INVALID][SMI_READ_WRITE] = INVALID;
- state_machine_[INVALID][SMI_VALID] = VALID;
- state_machine_[INVALID][SMI_UNDO_ALL] = INITIAL;
-}
-
-
-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) {
- state_ = INITIAL;
- } else {
- nextState(state_,
- input,
- state_machine_,
- "NoRepeatedApplyPolicy");
- }
-}
+++ /dev/null
-// -*- C++ -*-
-/* ButtonPolicies.h
- * Provides a state machine implementation of the various button policies
- * used by the dialogs.
- * Author: Allan Rae <rae@lyx.org>
- * This file is part of
- * ======================================================
- *
- * LyX, The Document Processor
- *
- * Copyright 1995 Matthias Ettrich
- * Copyright 1995-2000 The LyX Team.
- *
- * This file Copyright 2000
- * Allan Rae
- * ======================================================
- */
-
-#ifndef BUTTONPOLICIES_H
-#define BUTTONPOLICIES_H
-
-
-#include <vector>
-#include <boost/utility.hpp>
-
-#include "support/LOstream.h"
-
-/** An abstract base class for button policies.
- A state machine implementation of the various button policies used by the
- dialogs. Only the policy is implemented here. Separate ButtonController
- classes are needed for each GUI implementation.
-
- Policy | ReadOnly | Apply Button | Repeated Apply
- ========================================================================
- OkCancel | N | N | -
- OkCancelReadOnly | Y | N | -
- OkApplyCancel | N | Y | Y
- OkApplyCancelReadOnly | Y | Y | Y
- NoRepeatedApply | N | Y | N
- NoRepeatedApplyReadOnly | Y | Y | N
- Preferences | N | Y | No (Ok-Close)
- Ignorant | N/A | N/A | N/A
- ========================================================================
-
- Policy
- The name of the policy
- ReadOnly
- Does the policy treat read-only docs differently to read-write docs?
- This usually means that when an SMI_READ_ONLY input arrives then
- all the buttons are disabled except Cancel/Close. The state
- machine tracks the inputs (valid/invalid) and has states for all
- combinations. When an SMI_READ_WRITE input arrives the appropriate
- machine state is entered (just as if the document had always been
- read-write).
- NOTE: If a dialog doesn't care about the read-only status of a document
- (and uses an appropriate policy) it can never get into a read-only state
- so isReadOnly() can only ever return false even though the document may
- be read-only.
- Repeated Apply
- Simply means that it is alright to use the Apply button multiple times
- without requiring a change of the dialog contents. If no repeating is
- allowed the Ok+Apply buttons are deactivated. The Preferences dialog
- has its own special version of repeated apply handling because its Ok
- button is actually a Save button -- its always reasonable to Save the
- preferences if the dialog has changed since the last save.
-
- The IgnorantPolicy is a special case that allows anything.
- */
-class ButtonPolicy : public boost::noncopyable {
-public:
- ///
- virtual ~ButtonPolicy() {}
-
- /** The various possible state names.
- Not all state-machines have this many states. However, we need
- to define them all here so we can share the code.
- */
- enum State {
- ///
- INITIAL = 0,
- ///
- VALID,
- ///
- INVALID,
- ///
- APPLIED,
- ///
- RO_INITIAL,
- ///
- RO_VALID,
- ///
- RO_INVALID,
- ///
- RO_APPLIED,
- ///
- BOGUS = 55
- };
-
- /// The various button types.
- enum Button {
- ///
- CLOSE = 0, // Not a real button, but effectively !CANCEL
- ///
- OKAY = 1,
- ///
- APPLY = 2,
- ///
- CANCEL = 4,
- ///
- UNDO_ALL = 8
- };
- ///
- static const Button ALL_BUTTONS =
- Button(OKAY | APPLY | CANCEL | UNDO_ALL);
-
- /** State machine inputs.
- All the policies so far have both CANCEL and HIDE always going to
- INITIAL. This won't necessarily be true for all [future] policies
- though so I'll leave those two as distinct inputs rather than merge
- them. For example, a dialog that doesn't update it's input fields
- when reshown after being hidden needs a policy where CANCEL and
- HIDE are treated differently.
- */
- enum SMInput {
- ///
- SMI_VALID = 0,
- ///
- SMI_INVALID,
- ///
- SMI_OKAY,
- ///
- SMI_APPLY,
- ///
- SMI_CANCEL,
- ///
- SMI_UNDO_ALL,
- ///
- SMI_HIDE,
- ///
- SMI_READ_ONLY,
- ///
- SMI_READ_WRITE,
- ///
- SMI_TOTAL // not a real input
- };
-
- /// Trigger a transition with this input.
- virtual void input(SMInput) = 0;
- /// Activation status of a button
- virtual bool buttonStatus(Button) const = 0;
- /// Are we in a read-only state?
- virtual bool isReadOnly() const = 0;
-
- /// Transition map of the state machine.
- typedef std::vector<State> StateArray;
- ///
- typedef std::vector<StateArray> StateMachine;
- /// The state outputs are the status of the buttons.
- typedef std::vector<int> StateOutputs;
-};
-
-
-inline
-std::ostream & operator<<(std::ostream & os, ButtonPolicy::State st)
-{
- os << int(st);
- return os;
-}
-
-
-inline
-std::ostream & operator<<(std::ostream & os, ButtonPolicy::SMInput smi)
-{
- os << int(smi);
- return os;
-}
-
-
-//--------------------- Actual Policy Classes -----------------------------
-
-/** Ok and Cancel buttons for dialogs with read-only operation.
- Note: This scheme supports the relabelling of Cancel to Close and
- vice versa.
- This is based on the value of the bool state of the Button::CANCEL.
- true == Cancel, false == Close
- */
-class OkCancelPolicy : public ButtonPolicy {
-public:
- ///
- OkCancelPolicy();
- ///
- //virtual ~OkCancelPolicy() {}
-
- /// Trigger a transition with this input.
- virtual void input(SMInput);
- /** Activation status of a button.
- We assume that we haven't gotten into an undefined state.
- This is reasonable since we can only reach states defined
- in the state machine and they should all have been defined in
- the outputs_ variable. Perhaps we can do something at compile
- time to check that all the states have corresponding outputs.
- */
- virtual bool buttonStatus(Button button) const {
- return button & outputs_[state_];
- }
- /// Are we in a read-only state?
- virtual bool isReadOnly() const {
- return false;
- }
-private:
- /// Current state.
- State state_;
- /// Which buttons are active for a given state.
- StateOutputs outputs_;
- ///
- StateMachine state_machine_;
-};
-
-/** Ok and Cancel buttons for dialogs where read-only operation is blocked.
- The state machine design for this policy allows changes to occur within
- the dialog while a file is read-only -- the okay button is disabled until
- a read-write input is given. When the file is made read-write the dialog
- will then be in the correct state (as if the file had always been
- read-write).
- Note: This scheme supports the relabelling of Cancel to Close
- and vice versa.
- This is based on the value of the bool state of the Button::CANCEL.
- true == Cancel, false == Close
- */
-class OkCancelReadOnlyPolicy : public ButtonPolicy {
-public:
- ///
- OkCancelReadOnlyPolicy();
- ///
- //virtual ~OkCancelReadOnlyPolicy() {}
-
- /// Trigger a transition with this input.
- virtual void input(SMInput);
- /// Activation status of a button.
- virtual bool buttonStatus(Button button) const {
- return button & outputs_[state_];
- }
- /// Are we in a read-only state?
- virtual bool isReadOnly() const {
- return RO_INITIAL == state_
- || RO_VALID == state_
- || RO_INVALID == state_
- || RO_APPLIED == state_;
- }
-private:
- /// Current state.
- State state_;
- /// Which buttons are active for a given state.
- StateOutputs outputs_;
- ///
- StateMachine state_machine_;
-};
-
-
-/** Ok, Apply and Cancel buttons for dialogs where read-only operation
- is blocked.
- Repeated Apply are not allowed. Likewise, Ok cannot follow Apply without
- some valid input. That is, the dialog contents must change between
- each Apply or Apply and Ok.
- The state machine design for this policy allows changes to occur within
- the dialog while a file is read-only -- the Ok+Apply buttons are disabled
- until a read-write input is given. When the file is made read-write the
- dialog will then be in the correct state (as if the file had always been
- read-write).
- Note: This scheme supports the relabelling of Cancel to Close
- and vice versa.
- This is based on the value of the bool state of the Button::CANCEL.
- true == Cancel, false == Close
- */
-class NoRepeatedApplyReadOnlyPolicy : public ButtonPolicy
-{
-public:
- ///
- NoRepeatedApplyReadOnlyPolicy();
- ///
- //virtual ~NoRepeatedApplyReadOnlyPolicy() {}
-
- /// Trigger a transition with this input.
- virtual void input(SMInput);
- /// Activation status of a button.
- virtual bool buttonStatus(Button button) const {
- return button & outputs_[state_];
- }
- /// Are we in a read-only state?
- virtual bool isReadOnly() const {
- return RO_INITIAL == state_
- || RO_VALID == state_
- || RO_INVALID == state_
- || RO_APPLIED == state_;
- }
-private:
- /// Current state.
- State state_;
- /// Which buttons are active for a given state.
- StateOutputs outputs_;
- ///
- StateMachine state_machine_;
-};
-
-
-/** Ok, Apply and Cancel buttons for dialogs where read-only
- operation is blocked.
- Repeated Apply is allowed. Likewise, Ok can follow Apply.
- The state machine design for this policy allows changes to occur within
- the dialog while a file is read-only -- the Ok+Apply buttons are disabled
- until a read-write input is given. When the file is made read-write the
- dialog will then be in the correct state (as if the file had always been
- read-write).
- Note: This scheme supports the relabelling of Cancel to Close
- and vice versa.
- This is based on the value of the bool state of the Button::CANCEL.
- true == Cancel, false == Close
- */
-class OkApplyCancelReadOnlyPolicy : public ButtonPolicy {
-public:
- ///
- OkApplyCancelReadOnlyPolicy();
- ///
- //virtual ~OkApplyCancelReadOnlyPolicy() {}
-
- /// Trigger a transition with this input.
- virtual void input(SMInput);
- /// Activation status of a button.
- virtual bool buttonStatus(Button button) const {
- return button & outputs_[state_];
- }
- /// Are we in a read-only state?
- virtual bool isReadOnly() const {
- return RO_INITIAL == state_
- || RO_VALID == state_
- || RO_INVALID == state_
- || RO_APPLIED == state_;
- }
-private:
- /// Current state.
- State state_;
- /// Which buttons are active for a given state.
- StateOutputs outputs_;
- ///
- StateMachine state_machine_;
-};
-
-
-/** Ok, Apply and Cancel buttons for dialogs where repeated Apply is allowed.
- Note: This scheme supports the relabelling of Cancel to Close
- and vice versa.
- This is based on the value of the bool state of the Button::CANCEL.
- true == Cancel, false == Close
- */
-class OkApplyCancelPolicy : public ButtonPolicy {
-public:
- ///
- OkApplyCancelPolicy();
- ///
- //virtual ~OkApplyCancelPolicy() {}
-
- /// Trigger a transition with this input.
- virtual void input(SMInput);
- /// Activation status of a button.
- virtual bool buttonStatus(Button button) const {
- return button & outputs_[state_];
- }
- /// Are we in a read-only state?
- virtual bool isReadOnly() const {
- return false;
- }
-private:
- /// Current state.
- State state_;
- /// Which buttons are active for a given state.
- StateOutputs outputs_;
- ///
- StateMachine state_machine_;
-};
-
-
-/** Ok, Apply and Cancel buttons for dialogs with no repeated Apply.
- Note: This scheme supports the relabelling of Cancel to Close
- and vice versa.
- This is based on the value of the bool state of the Button::CANCEL.
- true == Cancel, false == Close
- */
-class NoRepeatedApplyPolicy : public ButtonPolicy {
-public:
- ///
- NoRepeatedApplyPolicy();
- ///
- //virtual ~NoRepeatedApplyPolicy() {}
-
- /// Trigger a transition with this input.
- virtual void input(SMInput);
- /// Activation status of a button.
- virtual bool buttonStatus(Button button) const {
- return button & outputs_[state_];
- }
- /// Are we in a read-only state?
- virtual bool isReadOnly() const {
- return false;
- }
-private:
- /// Current state.
- State state_;
- /// Which buttons are active for a given state.
- StateOutputs outputs_;
- ///
- StateMachine state_machine_;
-};
-
-
-/** Defines the policy used by the Preferences dialog.
- Four buttons: Ok (Save), Apply, Cancel/Close, Restore.
- Note: This scheme supports the relabelling of Cancel to Close
- and vice versa.
- This is based on the value of the bool state of the Button::CANCEL.
- true == Cancel, false == Close
- */
-class PreferencesPolicy : public ButtonPolicy {
-public:
- ///
- PreferencesPolicy();
- ///
- //virtual ~PreferencesPolicy() {}
-
- /// Trigger a transition with this input.
- virtual void input(SMInput);
- /// Activation status of a button.
- virtual bool buttonStatus(Button button) const {
- return button & outputs_[state_];
- }
- /// Are we in a read-only state?
- virtual bool isReadOnly() const {
- return false;
- }
-private:
- /// Current state.
- State state_;
- /// Which buttons are active for a given state.
- StateOutputs outputs_;
- ///
- StateMachine state_machine_;
-};
-
-
-/** Defines the policy used by dialogs that are forced to support a button
- controller when they either don't have a use for one or are not ready to
- use one. This may be useful when testing a new button policy but wishing
- to minimise problems to users by supplying an anything-goes policy via a
- preprocessor directive.
- */
-class IgnorantPolicy : public ButtonPolicy {
-public:
- //virtual ~IgnorantPolicy() {}
-
- /// Trigger a transition with this input.
- virtual void input(SMInput) {}
- /// Activation status of a button.
- virtual bool buttonStatus(Button) const {
- return true;
- }
- /// Are we in a read-only state?
- virtual bool isReadOnly() const {
- return false;
- }
-};
-
-#endif
+2001-03-20 Angus Leeming <a.leeming@ic.ac.uk>
+
+ * ButtonPolicies.[Ch]: removed (thought I did this before?). The files
+ are now stored in the controllers dir.
+
2001-03-16 Juergen Vigna <jug@sad.it>
* Dialogs.h (noncopyable): added minipage signals.
+2001-03-20 Angus Leeming <a.leeming@ic.ac.uk>
+
+ * ControlLog.[Ch]:
+ * ControlVCLog.[Ch]: new files; controllers for LaTeX and Version
+ Control log files, respectively.
+
+ * Makefile.am: added new files.
+
2001-03-19 Angus Leeming <a.leeming@ic.ac.uk>
* ControlBibtex.[Ch]: new files; controller for an InsetBibtex popup.
*
* LyX, The Document Processor
*
- * Copyright 2000 The LyX Team.
+ * Copyright 2001 The LyX Team.
*
* ======================================================
*
* \file ControlBibitem.C
+ * \author John Levon, moz@compsoc.man.ac.uk
* \author Angus Leeming <a.leeming@ic.ac.uk>
*/
*
* LyX, The Document Processor
*
- * Copyright 2000 The LyX Team.
+ * Copyright 2001 The LyX Team.
*
* ======================================================
*
* \file ControlBibitem.h
+ * \author John Levon, moz@compsoc.man.ac.uk
* \author Angus Leeming <a.leeming@ic.ac.uk>
*/
*
* LyX, The Document Processor
*
- * Copyright 2000 The LyX Team.
+ * Copyright 2001 The LyX Team.
*
* ======================================================
*
* \file ControlBibtex.C
+ * \author John Levon, moz@compsoc.man.ac.uk
* \author Angus Leeming <a.leeming@ic.ac.uk>
*/
*
* LyX, The Document Processor
*
- * Copyright 2000 The LyX Team.
+ * Copyright 2001 The LyX Team.
*
* ======================================================
*
* \file ControlBibtex.h
+ * \author John Levon, moz@compsoc.man.ac.uk
* \author Angus Leeming <a.leeming@ic.ac.uk>
*/
*
* LyX, The Document Processor
*
- * Copyright 2000 The LyX Team.
+ * Copyright 2001 The LyX Team.
*
* ======================================================
*
--- /dev/null
+/* This file is part of
+ * ======================================================
+ *
+ * LyX, The Document Processor
+ *
+ * Copyright 2001 The LyX Team.
+ *
+ * ======================================================
+ *
+ * \file ControlLog.h
+ * \author John Levon, moz@compsoc.man.ac.uk
+ * \author Angus Leeming <a.leeming@ic.ac.uk>
+ */
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include <config.h>
+#include "ButtonController.h"
+#include "ControlLog.h"
+#include "LyXView.h"
+#include "Dialogs.h"
+#include "lyxrc.h"
+#include "ViewBase.h"
+
+using std::make_pair;
+using SigC::slot;
+
+ControlLog::ControlLog(LyXView & lv, Dialogs & d)
+ : ControlConnectBD(lv, d)
+{
+ d_.showLogFile.connect(slot(this, &ControlLog::show));
+}
+
+
+void ControlLog::show()
+{
+ if (!lv_.view()->available())
+ return;
+
+ logfile_ = lv_.view()->buffer()->getLogName();
+
+ bc().readOnly(isReadonly());
+ view().show();
+}
+
+
+void ControlLog::update()
+{
+ if (!lv_.view()->available())
+ return;
+
+ logfile_ = lv_.view()->buffer()->getLogName();
+
+ bc().readOnly(isReadonly());
+ view().update();
+}
+
+
+void ControlLog::hide()
+{
+ logfile_.second.erase();
+ disconnect();
+ view().hide();
+}
--- /dev/null
+// -*- C++ -*-
+/* This file is part of
+ * ======================================================
+ *
+ * LyX, The Document Processor
+ *
+ * Copyright 2001 The LyX Team.
+ *
+ * ======================================================
+ *
+ * \file ControlLog.h
+ * \author John Levon, moz@compsoc.man.ac.uk
+ * \author Angus Leeming <a.leeming@ic.ac.uk>
+ */
+
+#ifndef CONTROLLOG_H
+#define CONTROLLOG_H
+
+#include <utility>
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "ControlConnections.h"
+#include "buffer.h" // Buffer::LogType
+
+/**
+ * A controller for a read-only text browser.
+ */
+class ControlLog : public ControlConnectBD {
+public:
+ ///
+ ControlLog(LyXView &, Dialogs &);
+ ///
+ std::pair<Buffer::LogType, string> const & logfile()
+ { return logfile_; }
+
+protected:
+ ///
+ virtual void apply() {}
+ /// Show the dialog.
+ virtual void show();
+ /// Update the dialog.
+ virtual void update();
+ /// Hide the dialog.
+ virtual void hide();
+
+private:
+ std::pair<Buffer::LogType, string> logfile_;
+};
+
+
+/** A class to instantiate and make available the GUI-specific
+ ButtonController and View.
+ */
+template <class GUIview, class GUIbc>
+class GUILog : public ControlLog {
+public:
+ ///
+ GUILog(LyXView &, Dialogs &);
+ ///
+ virtual ButtonControllerBase & bc() { return bc_; }
+ ///
+ virtual ViewBase & view() { return view_; }
+
+private:
+ ///
+ ButtonController<OkCancelPolicy, GUIbc> bc_;
+ ///
+ GUIview view_;
+};
+
+template <class GUIview, class GUIbc>
+GUILog<GUIview, GUIbc>::GUILog(LyXView & lv, Dialogs & d)
+ : ControlLog(lv, d),
+ view_(*this)
+{}
+
+#endif // CONTROLLOG_H
--- /dev/null
+/* This file is part of
+ * ======================================================
+ *
+ * LyX, The Document Processor
+ *
+ * Copyright 2001 The LyX Team.
+ *
+ * ======================================================
+ *
+ * \file ControlVCLog.h
+ * \author John Levon, moz@compsoc.man.ac.uk
+ * \author Angus Leeming <a.leeming@ic.ac.uk>
+ */
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include <config.h>
+#include "buffer.h"
+#include "ButtonController.h"
+#include "ControlVCLog.h"
+#include "LyXView.h"
+#include "Dialogs.h"
+#include "lyxrc.h"
+#include "ViewBase.h"
+
+using SigC::slot;
+
+ControlVCLog::ControlVCLog(LyXView & lv, Dialogs & d)
+ : ControlConnectBD(lv, d)
+{
+ d_.showVCLogFile.connect(slot(this, &ControlVCLog::show));
+}
+
+
+void ControlVCLog::show()
+{
+ if (!lv_.view()->available())
+ return;
+
+ logfile_ = lv_.view()->buffer()->lyxvc.getLogFile();
+
+ bc().readOnly(isReadonly());
+ view().show();
+}
+
+
+void ControlVCLog::update()
+{
+ if (!lv_.view()->available())
+ return;
+
+ logfile_ = lv_.view()->buffer()->lyxvc.getLogFile();
+
+ bc().readOnly(isReadonly());
+ view().update();
+
+ lyx::unlink(logfile_);
+}
+
+
+void ControlVCLog::hide()
+{
+ logfile_.erase();
+ disconnect();
+ view().hide();
+}
--- /dev/null
+// -*- C++ -*-
+/* This file is part of
+ * ======================================================
+ *
+ * LyX, The Document Processor
+ *
+ * Copyright 2001 The LyX Team.
+ *
+ * ======================================================
+ *
+ * \file ControlVCLog.h
+ * \author John Levon, moz@compsoc.man.ac.uk
+ * \author Angus Leeming <a.leeming@ic.ac.uk>
+ */
+
+#ifndef CONTROLVCLOG_H
+#define CONTROLVCLOG_H
+
+#include <utility>
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "ControlConnections.h"
+
+/**
+ * A controller for the Version Control log viewer.
+ */
+class ControlVCLog : public ControlConnectBD {
+public:
+ ///
+ ControlVCLog(LyXView &, Dialogs &);
+ ///
+ string const & logfile() { return logfile_; }
+
+protected:
+ ///
+ virtual void apply() {}
+ /// Show the dialog.
+ virtual void show();
+ /// Update the dialog.
+ virtual void update();
+ /// Hide the dialog.
+ virtual void hide();
+
+private:
+ string logfile_;
+};
+
+
+/** A class to instantiate and make available the GUI-specific
+ ButtonController and View.
+ */
+template <class GUIview, class GUIbc>
+class GUIVCLog : public ControlVCLog {
+public:
+ ///
+ GUIVCLog(LyXView &, Dialogs &);
+ ///
+ virtual ButtonControllerBase & bc() { return bc_; }
+ ///
+ virtual ViewBase & view() { return view_; }
+
+private:
+ ///
+ ButtonController<OkCancelPolicy, GUIbc> bc_;
+ ///
+ GUIview view_;
+};
+
+template <class GUIview, class GUIbc>
+GUIVCLog<GUIview, GUIbc>::GUIVCLog(LyXView & lv, Dialogs & d)
+ : ControlVCLog(lv, d),
+ view_(*this)
+{}
+
+#endif // CONTROLVCLOG_H
ControlCommand.h \
ControlConnections.C \
ControlConnections.h \
+ ControlLog.C \
+ ControlLog.h \
+ ControlVCLog.C \
+ ControlVCLog.h \
ViewBase.h
# just copied from old lyx repository
+2001-03-20 Angus Leeming <a.leeming@ic.ac.uk>
+
+ * FormBase.[Ch] (input): no longer pure virtual. Has defualt state of
+ SMI_NOOP.
+ (FormBase2): split into two template classes, FormDB (DialogBase) and
+ FormCB (ControllerBase) for greater flexibility.
+
+ * FormBibitem.[Ch]:
+ * FormBibtex.[Ch]:
+ * FormCitation.[Ch]: associated changes.
+
+ * FormBrowser.[Ch]:
+ * FormLog.[Ch]:
+ * FormVCLog.[Ch]:
+ * forms/form_browser.fd: implemented controller-view split.
+
+ * Dialogs.C: associated changes.
+
+2001-03-19 Angus Leeming <a.leeming@ic.ac.uk>
+
+ * FormBibtex.[Ch]:
+ * forms/form_bibtex.fd: implemented controller-view split.
+
+ * Dialogs.C: associated changes.
+
2001-03-19 Angus Leeming <a.leeming@ic.ac.uk>
* FormBibtex.[Ch]:
#include "ControlBibitem.h"
#include "ControlBibtex.h"
#include "ControlCitation.h"
+#include "ControlLog.h"
+#include "ControlVCLog.h"
#include "xformsBC.h"
+#include "form_bibitem.h" // needed for clean destructtion of boost::scoped ptr
+#include "form_bibtex.h"
+#include "form_browser.h"
+#include "form_citation.h"
+
#include "FormBibitem.h"
#include "FormBibtex.h"
#include "FormCitation.h"
+#include "FormLog.h"
+#include "FormVCLog.h"
+
#include "FormCharacter.h"
#include "FormCopyright.h"
#include "FormCredits.h"
#include "FormGraphics.h"
#include "FormInclude.h"
#include "FormIndex.h"
-#include "FormLog.h"
#include "FormMathsPanel.h"
#include "FormParagraph.h"
#include "FormPreamble.h"
#include "FormTabularCreate.h"
#include "FormToc.h"
#include "FormUrl.h"
-#include "FormVCLog.h"
#include "FormMinipage.h"
// Signal enabling all visible popups to be redrawn if so desired.
add(new GUICitation<FormCitation, xformsBC>(*lv, *this));
add(new GUIBibitem<FormBibitem, xformsBC>(*lv, *this));
add(new GUIBibtex<FormBibtex, xformsBC>(*lv, *this));
+ add(new GUILog<FormLog, xformsBC>(*lv, *this));
+ add(new GUIVCLog<FormVCLog, xformsBC>(*lv, *this));
add(new FormCharacter(lv, this));
add(new FormCopyright(lv, this));
add(new FormGraphics(lv, this));
add(new FormInclude(lv, this));
add(new FormIndex(lv, this));
- add(new FormLog(lv, this));
add(new FormMathsPanel(lv, this));
add(new FormParagraph(lv, this));
add(new FormPreamble(lv, this));
add(new FormTabularCreate(lv, this));
add(new FormToc(lv, this));
add(new FormUrl(lv, this));
- add(new FormVCLog(lv, this));
add(new FormMinipage(lv, this));
// reduce the number of connections needed in
* Copyright 2000 The LyX Team.
*
* ======================================================
+ *
+ * \author Angus Leeming <a.leeming@ic.ac.uk>
*/
#include <config.h>
}
+ButtonPolicy::SMInput FormBase::input(FL_OBJECT *, long)
+{
+ return ButtonPolicy::SMI_NOOP;
+}
+
+
namespace {
FormBase * GetForm(FL_OBJECT * ob)
*
* ======================================================
*
- * Author: Angus Leeming <a.leeming@ic.ac.uk>
+ * \author Angus Leeming <a.leeming@ic.ac.uk>
*/
#ifndef FORMBASE_H
virtual FL_FORM * form() const = 0;
/** Filter the inputs on callback from xforms
Return true if inputs are valid. */
- virtual ButtonPolicy::SMInput input(FL_OBJECT *, long) = 0;
+ virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
/** Redraw the form (on receipt of a Signal indicating, for example,
that the xform colors have been re-mapped). */
};
-template <class Controller, class Dialog>
-class FormBase2: public FormBase
+template <class Dialog>
+class FormDB: public FormBase
{
protected:
///
- FormBase2(ControlBase &, string const &);
- /// The parent controller
- Controller & controller() const;
+ FormDB(ControlBase &, string const &);
/// Pointer to the actual instantiation of xform's form
virtual FL_FORM * form() const;
/// Real GUI implementation.
};
-template <class Controller, class Dialog>
-FormBase2<Controller, Dialog>::FormBase2(ControlBase & c, string const & t)
+template <class Dialog>
+FormDB<Dialog>::FormDB(ControlBase & c, string const & t)
: FormBase(c, t)
{}
-template <class Controller, class Dialog>
-Controller & FormBase2<Controller, Dialog>::controller() const
+template <class Dialog>
+FL_FORM * FormDB<Dialog>::form() const
{
- return static_cast<Controller &>(controller_);
- //return dynamic_cast<Controller &>(controller_);
+ if (dialog_.get()) return dialog_->form;
+ return 0;
}
-template <class Controller, class Dialog>
-FL_FORM * FormBase2<Controller, Dialog>::form() const
+template <class Controller, class Base>
+class FormCB: public Base
{
- if (dialog_.get()) return dialog_->form;
- return 0;
+protected:
+ ///
+ FormCB(ControlBase &, string const &);
+ /// The parent controller
+ Controller & controller() const;
+};
+
+
+template <class Controller, class Base>
+FormCB<Controller, Base>::FormCB(ControlBase & c, string const & t)
+ : Base(c, t)
+{}
+
+
+template <class Controller, class Base>
+Controller & FormCB<Controller, Base>::controller() const
+{
+ return static_cast<Controller &>(controller_);
+ //return dynamic_cast<Controller &>(controller_);
}
#include <config.h>
#include "ControlBibitem.h"
#include "FormBibitem.h"
+#include "form_bibitem.h"
#include "gettext.h"
#include "xformsBC.h"
#include "support/lstrings.h" // compare
+typedef FormCB<ControlBibitem, FormDB<FD_form_bibitem> > base_class;
+
FormBibitem::FormBibitem(ControlBibitem & c)
- : FormBase2<ControlBibitem, FD_form_bibitem>(c, _("Bibliography Entry"))
+ : base_class(c, _("Bibliography Entry"))
{}
* Copyright 2001 the LyX Team
* Read the file COPYING
*
- * \author Angus Leeming
- * \author John Levon
+ * \author John Levon, moz@compsoc.man.ac.uk
+ * \author Angus Leeming, a.leeming@.ac.uk
*/
#ifndef FORMBIBITEM_H
#include "FormBase.h"
-#include "form_bibitem.h"
-
class ControlBibitem;
+struct FD_form_bibitem;
/**
* For bibliography entry editing
*/
-class FormBibitem : public FormBase2<ControlBibitem, FD_form_bibitem> {
+class FormBibitem : public FormCB<ControlBibitem, FormDB<FD_form_bibitem> > {
public:
///
FormBibitem(ControlBibitem &);
#include <config.h>
#include "ControlBibtex.h"
#include "FormBibtex.h"
+#include "form_bibtex.h"
#include "gettext.h"
#include "xformsBC.h"
#include "debug.h"
+typedef FormCB<ControlBibtex, FormDB<FD_form_bibtex> > base_class;
+
FormBibtex::FormBibtex(ControlBibtex & c)
- : FormBase2<ControlBibtex, FD_form_bibtex>(c, _("BibTeX Database"))
+ : base_class(c, _("BibTeX Database"))
{}
#include "FormBase.h"
-#include "form_bibtex.h"
-
class ControlBibtex;
+struct FD_form_bibtex;
/**
* For bibtex database setting
*/
-class FormBibtex : public FormBase2<ControlBibtex, FD_form_bibtex> {
+class FormBibtex : public FormCB<ControlBibtex, FormDB<FD_form_bibtex> > {
public:
///
FormBibtex(ControlBibtex &);
* John Levon, moz@compsoc.man.ac.uk
*/
-#include <config.h>
-
-#include FORMS_H_LOCATION
-
#ifdef __GNUG__
#pragma implementation
#endif
-#include "gettext.h"
+#include <config.h>
#include "FormBrowser.h"
#include "form_browser.h"
-#include "LyXView.h"
-#include "Dialogs.h"
-#include "lyxrc.h"
-#include "buffer.h"
+#include "xformsBC.h"
-FormBrowser::FormBrowser(LyXView * lv, Dialogs * d, const string & name)
- : FormBaseBD(lv, d, name)
+FormBrowser::FormBrowser(ControlBase & c, string const & t)
+ : FormDB<FD_form_browser>(c, t)
{}
-
+
void FormBrowser::build()
{
bc().setCancel(dialog_->button_close);
bc().refresh();
}
-
-
-FL_FORM * FormBrowser::form() const
-{
- if (dialog_.get())
- return dialog_->form;
- return 0;
-}
-
-void FormBrowser::update()
-{}
-
-
-bool FormBrowser::input(FL_OBJECT *, long)
-{
- update();
- return true;
-}
// -*- C++ -*-
/*
- * FormBrowser.h
+ * \file FormBrowser.h
*
* (C) 2001 LyX Team
* John Levon, moz@compsoc.man.ac.uk
+ * \author Angus Leeming, a.leeming@.ac.uk
*/
#ifndef FORMBROWSER_H
#define FORMBROWSER_H
-#include <boost/smart_ptr.hpp>
-
#ifdef __GNUG__
#pragma interface
#endif
-#include "FormBaseDeprecated.h"
-
-struct FD_form_browser;
+#include "FormBase.h"
/**
* This class provides an XForms implementation of a read only
* text browser.
*/
-class FormBrowser : public FormBaseBD {
+struct FD_form_browser;
+
+class FormBrowser : public FormDB<FD_form_browser> {
public:
///
- FormBrowser(LyXView *, Dialogs *, const string &);
-protected:
- /// Update the dialog.
- virtual void update();
+ FormBrowser(ControlBase &, string const &);
- /// Real GUI implementation.
- boost::scoped_ptr<FD_form_browser> dialog_;
- /// Pointer to the actual instantiation of the ButtonController.
- virtual xformsBC & bc();
private:
- /// Pointer to the actual instantiation of the xforms form
- virtual FL_FORM * form() const;
- /// Filter the inputs on callback from xforms
- virtual bool input(FL_OBJECT *, long);
- /// Build the dialog
+ /// Build the dialog.
virtual void build();
-
/// generated build function
FD_form_browser * build_browser();
- /// The ButtonController
- ButtonController<OkCancelPolicy, xformsBC> bc_;
};
-
-inline
-xformsBC & FormBrowser::bc()
-{
- return bc_;
-}
-#endif
+#endif // FORMBROWSER_H
* Copyright 2000 The LyX Team.
*
* ======================================================
+ *
+ * \author Angus Leeming <a.leeming@ic.ac.uk>
*/
#include <algorithm>
using std::sort;
using std::vector;
+typedef FormCB<ControlCitation, FormDB<FD_form_citation> > base_class;
+
FormCitation::FormCitation(ControlCitation & c)
- : FormBase2<ControlCitation, FD_form_citation>(c, _("Citation"))
+ : base_class(c, _("Citation"))
{}
ControlCitation::REGEX : ControlCitation::SIMPLE;
vector<string>::const_iterator start = bibkeys.begin();
- unsigned int const sel = fl_get_browser(dialog_->browser_bib);
+ int const sel = fl_get_browser(dialog_->browser_bib);
if (sel >= 1 && sel <= bibkeys.size())
start += sel-1;
*
* ======================================================
*
- * Author: Angus Leeming <a.leeming@ic.ac.uk>
+ * \author Angus Leeming <a.leeming@ic.ac.uk>
*/
#ifndef FORMCITATION_H
/** This class provides an XForms implementation of the Citation Dialog.
*/
-#include "form_citation.h"
class ControlCitation;
+struct FD_form_citation;
-class FormCitation : public FormBase2<ControlCitation, FD_form_citation> {
+class FormCitation : public FormCB<ControlCitation, FormDB<FD_form_citation> > {
public:
///
FormCitation(ControlCitation &);
* John Levon, moz@compsoc.man.ac.uk
*/
-#include <config.h>
-
-#include FORMS_H_LOCATION
-
#ifdef __GNUG__
#pragma implementation
#endif
-#include "gettext.h"
+#include <config.h>
+#include "xformsBC.h"
+#include "ControlLog.h"
#include "FormLog.h"
#include "form_browser.h"
-#include "LyXView.h"
-#include "Dialogs.h"
-#include "lyxrc.h"
-#include "buffer.h"
+#include "gettext.h"
-using SigC::slot;
-
-FormLog::FormLog(LyXView * lv, Dialogs * d)
- : FormBrowser(lv, d, _("LaTeX Log"))
-{
- // let the dialog be shown
- // This is a permanent connection so we won't bother
- // storing a copy because we won't be disconnecting.
- d->showLogFile.connect(slot(this, &FormLog::show));
-}
+FormLog::FormLog(ControlLog & c)
+ : FormCB<ControlLog, FormBrowser>(c, _("LaTeX Log"))
+{}
void FormLog::update()
{
- if (!dialog_.get() || !lv_->view()->available())
- return;
-
- std::pair<Buffer::LogType, string> const logfile
- = lv_->view()->buffer()->getLogName();
-
fl_clear_browser(dialog_->browser);
- if (logfile.first == Buffer::buildlog) {
+ if (controller().logfile().first == Buffer::buildlog) {
fl_set_form_title(dialog_->form, _("Build log"));
- if (!fl_load_browser(dialog_->browser, logfile.second.c_str()))
+ if (!fl_load_browser(dialog_->browser,
+ controller().logfile().second.c_str()))
fl_add_browser_line(dialog_->browser,
_("No build log file found"));
return;
}
fl_set_form_title(dialog_->form, _("LaTeX Log"));
- if (!fl_load_browser(dialog_->browser, logfile.second.c_str()))
+ if (!fl_load_browser(dialog_->browser,
+ controller().logfile().second.c_str()))
fl_add_browser_line(dialog_->browser,
_("No LaTeX log file found"));
}
#ifndef FORMLOG_H
#define FORMLOG_H
-#include "FormBaseDeprecated.h"
-#include "FormBrowser.h"
-
#ifdef __GNUG__
#pragma interface
#endif
-class LyXView;
-class Dialogs;
+#include "FormBrowser.h"
+
+class ControlLog;
/**
* This class provides an XForms implementation of the LaTeX log dialog
* for viewing the last LaTeX log file.
*/
-class FormLog : public FormBrowser {
+class FormLog : public FormCB<ControlLog, FormBrowser> {
public:
///
- FormLog(LyXView *, Dialogs *);
-private:
- /// Update the dialog.
+ FormLog(ControlLog &);
+
+ // Functions accessible to the Controller.
+
+ /// Set the Params variable for the Controller.
+ virtual void apply() {}
+ /// Update dialog before/whilst showing it.
virtual void update();
};
-#endif
+#endif // FORMLOG_H
#include "MathsSymbols.h"
#include "debug.h"
+#include "form_maths_deco.h"
+#include "form_maths_delim.h"
+#include "form_maths_matrix.h"
+#include "form_maths_space.h"
+
#include "FormMathsBitmap.h"
#include "FormMathsDeco.h"
-#include "form_maths_deco.h"
#include "FormMathsDelim.h"
-#include "form_maths_delim.h"
#include "FormMathsMatrix.h"
-#include "form_maths_matrix.h"
#include "FormMathsSpace.h"
-#include "form_maths_space.h"
#include "deco.xpm"
#include "delim.xpm"
* John Levon, moz@compsoc.man.ac.uk
*/
-#include <config.h>
-
-#include FORMS_H_LOCATION
-
#ifdef __GNUG__
#pragma implementation
#endif
-#include "gettext.h"
+#include <config.h>
+#include "xformsBC.h"
+#include "ControlVCLog.h"
#include "FormVCLog.h"
#include "form_browser.h"
-#include "LyXView.h"
-#include "Dialogs.h"
-#include "lyxrc.h"
-#include "buffer.h"
+#include "gettext.h"
-using SigC::slot;
-
-FormVCLog::FormVCLog(LyXView * lv, Dialogs * d)
- : FormBrowser(lv, d, _("Version Control Log"))
-{
- // let the dialog be shown
- // This is a permanent connection so we won't bother
- // storing a copy because we won't be disconnecting.
- d->showVCLogFile.connect(slot(this, &FormVCLog::show));
-}
+FormVCLog::FormVCLog(ControlVCLog & c)
+ : FormCB<ControlVCLog, FormBrowser>(c, _("Version Control Log"))
+{}
void FormVCLog::update()
{
- if (!dialog_.get() || !lv_->view()->available())
- return;
-
- const string logfile = lv_->view()->buffer()->lyxvc.getLogFile();
-
fl_clear_browser(dialog_->browser);
- if (logfile=="" || !fl_load_browser(dialog_->browser, logfile.c_str()))
- fl_add_browser_line(dialog_->browser, _("No version control log file available"));
-
- lyx::unlink(logfile);
+ if (controller().logfile().empty() ||
+ !fl_load_browser(dialog_->browser, controller().logfile().c_str()))
+ fl_add_browser_line(dialog_->browser,
+ _("No version control log file available"));
}
#ifndef FORMVCLOG_H
#define FORMVCLOG_H
-#include "FormBaseDeprecated.h"
-#include "FormBrowser.h"
-
#ifdef __GNUG__
#pragma interface
#endif
-class LyXView;
-class Dialogs;
+#include "FormBrowser.h"
+
+class ControlVCLog;
/**
* This class provides an XForms implementation of the Version Control
* log viewer
*/
-class FormVCLog : public FormBrowser {
+class FormVCLog : public FormCB<ControlVCLog, FormBrowser> {
public:
///
- FormVCLog(LyXView *, Dialogs *);
-private:
- /// Update the dialog.
+ FormVCLog(ControlVCLog &);
+
+ // Functions accessible to the Controller.
+
+ /// Set the Params variable for the Controller.
+ virtual void apply() {}
+ /// Update dialog before/whilst showing it.
virtual void update();
};
-#endif
+#endif // FORMVCLOG_H
}
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
- fl_set_object_callback(obj, C_FormBaseDeprecatedCancelCB, 0);
+ fl_set_object_callback(obj, C_FormBaseCancelCB, 0);
{
char const * const dummy = N_("Update|#Uu");
fdui->button_update = obj = fl_add_button(FL_NORMAL_BUTTON, 270, 340, 90, 30, idex(_(dummy)));
}
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
- fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
+ fl_set_object_callback(obj, C_FormBaseRestoreCB, 0);
fl_end_form();
fdui->form->fdui = fdui;
#define FD_form_browser_h_
/** Callbacks, globals and object handlers **/
-extern "C" void C_FormBaseDeprecatedCancelCB(FL_OBJECT *, long);
-extern "C" void C_FormBaseDeprecatedInputCB(FL_OBJECT *, long);
+extern "C" void C_FormBaseCancelCB(FL_OBJECT *, long);
+extern "C" void C_FormBaseRestoreCB(FL_OBJECT *, long);
/**** Forms and Objects ****/
resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: button_close
-callback: C_FormBaseDeprecatedCancelCB
+callback: C_FormBaseCancelCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: button_update
-callback: C_FormBaseDeprecatedInputCB
+callback: C_FormBaseRestoreCB
argument: 0
==============================
+2001-03-20 Angus Leeming <a.leeming@ic.ac.uk>
+
+ * figinset.C (fl_set_preemptive_callback): moved definition outside
+ of namespace anon.
+
2001-03-20 Lars Gullik Bjønnes <larsbj@trylle.birdstep.com>
* insetminipage.C (Read): prepare for reading of minipage arguments.
extern char ** environ; // is this only redundtant on linux systems? Lgb.
+// xforms doesn't define this (but it should be in <forms.h>).
+extern "C"
+FL_APPEVENT_CB fl_set_preemptive_callback(Window, FL_APPEVENT_CB, void *);
+
namespace {
float const DEG2PI = 57.295779513;
gs_color = true;
}
-
-// xforms doesn't define this
-extern "C"
-FL_APPEVENT_CB fl_set_preemptive_callback(Window, FL_APPEVENT_CB, void *);
-
-
void InitFigures()
{
// if bitmaps and figures are not empty we will leak mem