From: Angus Leeming Date: Tue, 20 Mar 2001 10:14:03 +0000 (+0000) Subject: controller-view split of FormLog and FormVCLog. X-Git-Tag: 1.6.10~21430 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=9f29ab3aa5fb11baca9bc28dc3710076cb3a2645;p=features.git controller-view split of FormLog and FormVCLog. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1796 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/ButtonPolicies.C b/src/frontends/ButtonPolicies.C deleted file mode 100644 index 89c09018b3..0000000000 --- a/src/frontends/ButtonPolicies.C +++ /dev/null @@ -1,548 +0,0 @@ -// -*- C++ -*- -/* ButtonPolicies.C - * Provides a state machine implementation of the various button policies - * used by the dialogs. - * Author: Allan Rae - * 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 - -#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"); - } -} diff --git a/src/frontends/ButtonPolicies.h b/src/frontends/ButtonPolicies.h deleted file mode 100644 index a3603b67b3..0000000000 --- a/src/frontends/ButtonPolicies.h +++ /dev/null @@ -1,471 +0,0 @@ -// -*- C++ -*- -/* ButtonPolicies.h - * Provides a state machine implementation of the various button policies - * used by the dialogs. - * Author: Allan Rae - * 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 -#include - -#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 StateArray; - /// - typedef std::vector StateMachine; - /// The state outputs are the status of the buttons. - typedef std::vector 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 diff --git a/src/frontends/ChangeLog b/src/frontends/ChangeLog index 2044533b07..a76f3d3d00 100644 --- a/src/frontends/ChangeLog +++ b/src/frontends/ChangeLog @@ -1,3 +1,8 @@ +2001-03-20 Angus Leeming + + * ButtonPolicies.[Ch]: removed (thought I did this before?). The files + are now stored in the controllers dir. + 2001-03-16 Juergen Vigna * Dialogs.h (noncopyable): added minipage signals. diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index b84d2a3dde..dfb923b5ba 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,11 @@ +2001-03-20 Angus Leeming + + * 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 * ControlBibtex.[Ch]: new files; controller for an InsetBibtex popup. diff --git a/src/frontends/controllers/ControlBibitem.C b/src/frontends/controllers/ControlBibitem.C index 416983a992..3ca711a592 100644 --- a/src/frontends/controllers/ControlBibitem.C +++ b/src/frontends/controllers/ControlBibitem.C @@ -4,11 +4,12 @@ * * 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 */ diff --git a/src/frontends/controllers/ControlBibitem.h b/src/frontends/controllers/ControlBibitem.h index 98b7bb5308..e6ead2ad8d 100644 --- a/src/frontends/controllers/ControlBibitem.h +++ b/src/frontends/controllers/ControlBibitem.h @@ -4,11 +4,12 @@ * * 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 */ diff --git a/src/frontends/controllers/ControlBibtex.C b/src/frontends/controllers/ControlBibtex.C index 8614b105bb..0692d60982 100644 --- a/src/frontends/controllers/ControlBibtex.C +++ b/src/frontends/controllers/ControlBibtex.C @@ -4,11 +4,12 @@ * * 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 */ diff --git a/src/frontends/controllers/ControlBibtex.h b/src/frontends/controllers/ControlBibtex.h index 4699427292..2771ed36d5 100644 --- a/src/frontends/controllers/ControlBibtex.h +++ b/src/frontends/controllers/ControlBibtex.h @@ -4,11 +4,12 @@ * * 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 */ diff --git a/src/frontends/controllers/ControlCommand.C b/src/frontends/controllers/ControlCommand.C index b19c7c7219..bc2744db00 100644 --- a/src/frontends/controllers/ControlCommand.C +++ b/src/frontends/controllers/ControlCommand.C @@ -4,7 +4,7 @@ * * LyX, The Document Processor * - * Copyright 2000 The LyX Team. + * Copyright 2001 The LyX Team. * * ====================================================== * diff --git a/src/frontends/controllers/ControlLog.C b/src/frontends/controllers/ControlLog.C new file mode 100644 index 0000000000..ff00b6cf56 --- /dev/null +++ b/src/frontends/controllers/ControlLog.C @@ -0,0 +1,66 @@ +/* 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 + */ + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include +#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(); +} diff --git a/src/frontends/controllers/ControlLog.h b/src/frontends/controllers/ControlLog.h new file mode 100644 index 0000000000..63d66e6540 --- /dev/null +++ b/src/frontends/controllers/ControlLog.h @@ -0,0 +1,80 @@ +// -*- 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 + */ + +#ifndef CONTROLLOG_H +#define CONTROLLOG_H + +#include + +#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 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 logfile_; +}; + + +/** A class to instantiate and make available the GUI-specific + ButtonController and View. + */ +template +class GUILog : public ControlLog { +public: + /// + GUILog(LyXView &, Dialogs &); + /// + virtual ButtonControllerBase & bc() { return bc_; } + /// + virtual ViewBase & view() { return view_; } + +private: + /// + ButtonController bc_; + /// + GUIview view_; +}; + +template +GUILog::GUILog(LyXView & lv, Dialogs & d) + : ControlLog(lv, d), + view_(*this) +{} + +#endif // CONTROLLOG_H diff --git a/src/frontends/controllers/ControlVCLog.C b/src/frontends/controllers/ControlVCLog.C new file mode 100644 index 0000000000..acba9d795c --- /dev/null +++ b/src/frontends/controllers/ControlVCLog.C @@ -0,0 +1,68 @@ +/* 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 + */ + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include +#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(); +} diff --git a/src/frontends/controllers/ControlVCLog.h b/src/frontends/controllers/ControlVCLog.h new file mode 100644 index 0000000000..6da6c7b96d --- /dev/null +++ b/src/frontends/controllers/ControlVCLog.h @@ -0,0 +1,78 @@ +// -*- 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 + */ + +#ifndef CONTROLVCLOG_H +#define CONTROLVCLOG_H + +#include + +#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 GUIVCLog : public ControlVCLog { +public: + /// + GUIVCLog(LyXView &, Dialogs &); + /// + virtual ButtonControllerBase & bc() { return bc_; } + /// + virtual ViewBase & view() { return view_; } + +private: + /// + ButtonController bc_; + /// + GUIview view_; +}; + +template +GUIVCLog::GUIVCLog(LyXView & lv, Dialogs & d) + : ControlVCLog(lv, d), + view_(*this) +{} + +#endif // CONTROLVCLOG_H diff --git a/src/frontends/controllers/Makefile.am b/src/frontends/controllers/Makefile.am index 53bc704593..65fcafb648 100644 --- a/src/frontends/controllers/Makefile.am +++ b/src/frontends/controllers/Makefile.am @@ -26,6 +26,10 @@ libcontrollers_la_SOURCES=\ ControlCommand.h \ ControlConnections.C \ ControlConnections.h \ + ControlLog.C \ + ControlLog.h \ + ControlVCLog.C \ + ControlVCLog.h \ ViewBase.h # just copied from old lyx repository diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 5b8dee4181..b17729df06 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,28 @@ +2001-03-20 Angus Leeming + + * 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 + + * FormBibtex.[Ch]: + * forms/form_bibtex.fd: implemented controller-view split. + + * Dialogs.C: associated changes. + 2001-03-19 Angus Leeming * FormBibtex.[Ch]: diff --git a/src/frontends/xforms/Dialogs.C b/src/frontends/xforms/Dialogs.C index b1b6b9d520..776df33c40 100644 --- a/src/frontends/xforms/Dialogs.C +++ b/src/frontends/xforms/Dialogs.C @@ -20,11 +20,21 @@ #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" @@ -34,7 +44,6 @@ #include "FormGraphics.h" #include "FormInclude.h" #include "FormIndex.h" -#include "FormLog.h" #include "FormMathsPanel.h" #include "FormParagraph.h" #include "FormPreamble.h" @@ -47,7 +56,6 @@ #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. @@ -61,6 +69,8 @@ Dialogs::Dialogs(LyXView * lv) add(new GUICitation(*lv, *this)); add(new GUIBibitem(*lv, *this)); add(new GUIBibtex(*lv, *this)); + add(new GUILog(*lv, *this)); + add(new GUIVCLog(*lv, *this)); add(new FormCharacter(lv, this)); add(new FormCopyright(lv, this)); @@ -71,7 +81,6 @@ Dialogs::Dialogs(LyXView * lv) 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)); @@ -84,7 +93,6 @@ Dialogs::Dialogs(LyXView * lv) 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 diff --git a/src/frontends/xforms/FormBase.C b/src/frontends/xforms/FormBase.C index d2547f6320..30cfc33d0c 100644 --- a/src/frontends/xforms/FormBase.C +++ b/src/frontends/xforms/FormBase.C @@ -7,6 +7,8 @@ * Copyright 2000 The LyX Team. * * ====================================================== + * + * \author Angus Leeming */ #include @@ -87,6 +89,12 @@ void FormBase::InputCB(FL_OBJECT * ob, long data) } +ButtonPolicy::SMInput FormBase::input(FL_OBJECT *, long) +{ + return ButtonPolicy::SMI_NOOP; +} + + namespace { FormBase * GetForm(FL_OBJECT * ob) diff --git a/src/frontends/xforms/FormBase.h b/src/frontends/xforms/FormBase.h index 8668e3722f..fe7761e2fe 100644 --- a/src/frontends/xforms/FormBase.h +++ b/src/frontends/xforms/FormBase.h @@ -8,7 +8,7 @@ * * ====================================================== * - * Author: Angus Leeming + * \author Angus Leeming */ #ifndef FORMBASE_H @@ -53,7 +53,7 @@ private: 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). */ @@ -71,14 +71,12 @@ private: }; -template -class FormBase2: public FormBase +template +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. @@ -86,25 +84,42 @@ protected: }; -template -FormBase2::FormBase2(ControlBase & c, string const & t) +template +FormDB::FormDB(ControlBase & c, string const & t) : FormBase(c, t) {} -template -Controller & FormBase2::controller() const +template +FL_FORM * FormDB::form() const { - return static_cast(controller_); - //return dynamic_cast(controller_); + if (dialog_.get()) return dialog_->form; + return 0; } -template -FL_FORM * FormBase2::form() const +template +class FormCB: public Base { - if (dialog_.get()) return dialog_->form; - return 0; +protected: + /// + FormCB(ControlBase &, string const &); + /// The parent controller + Controller & controller() const; +}; + + +template +FormCB::FormCB(ControlBase & c, string const & t) + : Base(c, t) +{} + + +template +Controller & FormCB::controller() const +{ + return static_cast(controller_); + //return dynamic_cast(controller_); } diff --git a/src/frontends/xforms/FormBibitem.C b/src/frontends/xforms/FormBibitem.C index d23831c753..69aeb1afa5 100644 --- a/src/frontends/xforms/FormBibitem.C +++ b/src/frontends/xforms/FormBibitem.C @@ -14,12 +14,15 @@ #include #include "ControlBibitem.h" #include "FormBibitem.h" +#include "form_bibitem.h" #include "gettext.h" #include "xformsBC.h" #include "support/lstrings.h" // compare +typedef FormCB > base_class; + FormBibitem::FormBibitem(ControlBibitem & c) - : FormBase2(c, _("Bibliography Entry")) + : base_class(c, _("Bibliography Entry")) {} diff --git a/src/frontends/xforms/FormBibitem.h b/src/frontends/xforms/FormBibitem.h index f103d12e27..3016ab6aaf 100644 --- a/src/frontends/xforms/FormBibitem.h +++ b/src/frontends/xforms/FormBibitem.h @@ -4,8 +4,8 @@ * 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 @@ -17,14 +17,13 @@ #include "FormBase.h" -#include "form_bibitem.h" - class ControlBibitem; +struct FD_form_bibitem; /** * For bibliography entry editing */ -class FormBibitem : public FormBase2 { +class FormBibitem : public FormCB > { public: /// FormBibitem(ControlBibitem &); diff --git a/src/frontends/xforms/FormBibtex.C b/src/frontends/xforms/FormBibtex.C index 2f32c2434b..333a8f4cf7 100644 --- a/src/frontends/xforms/FormBibtex.C +++ b/src/frontends/xforms/FormBibtex.C @@ -14,12 +14,15 @@ #include #include "ControlBibtex.h" #include "FormBibtex.h" +#include "form_bibtex.h" #include "gettext.h" #include "xformsBC.h" #include "debug.h" +typedef FormCB > base_class; + FormBibtex::FormBibtex(ControlBibtex & c) - : FormBase2(c, _("BibTeX Database")) + : base_class(c, _("BibTeX Database")) {} diff --git a/src/frontends/xforms/FormBibtex.h b/src/frontends/xforms/FormBibtex.h index ce9ca1d378..452cab7d59 100644 --- a/src/frontends/xforms/FormBibtex.h +++ b/src/frontends/xforms/FormBibtex.h @@ -17,14 +17,13 @@ #include "FormBase.h" -#include "form_bibtex.h" - class ControlBibtex; +struct FD_form_bibtex; /** * For bibtex database setting */ -class FormBibtex : public FormBase2 { +class FormBibtex : public FormCB > { public: /// FormBibtex(ControlBibtex &); diff --git a/src/frontends/xforms/FormBrowser.C b/src/frontends/xforms/FormBrowser.C index 7641dddec9..2b2aae8f81 100644 --- a/src/frontends/xforms/FormBrowser.C +++ b/src/frontends/xforms/FormBrowser.C @@ -3,26 +3,19 @@ * John Levon, moz@compsoc.man.ac.uk */ -#include - -#include FORMS_H_LOCATION - #ifdef __GNUG__ #pragma implementation #endif -#include "gettext.h" +#include #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(c, t) {} - + void FormBrowser::build() { @@ -32,21 +25,3 @@ 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; -} diff --git a/src/frontends/xforms/FormBrowser.h b/src/frontends/xforms/FormBrowser.h index 6de60da1d4..6e601ef2b8 100644 --- a/src/frontends/xforms/FormBrowser.h +++ b/src/frontends/xforms/FormBrowser.h @@ -1,58 +1,37 @@ // -*- 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 - #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 { public: /// - FormBrowser(LyXView *, Dialogs *, const string &); -protected: - /// Update the dialog. - virtual void update(); + FormBrowser(ControlBase &, string const &); - /// Real GUI implementation. - boost::scoped_ptr 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 bc_; }; - -inline -xformsBC & FormBrowser::bc() -{ - return bc_; -} -#endif +#endif // FORMBROWSER_H diff --git a/src/frontends/xforms/FormCitation.C b/src/frontends/xforms/FormCitation.C index 0e65ed6177..eb63893974 100644 --- a/src/frontends/xforms/FormCitation.C +++ b/src/frontends/xforms/FormCitation.C @@ -7,6 +7,8 @@ * Copyright 2000 The LyX Team. * * ====================================================== + * + * \author Angus Leeming */ #include @@ -31,8 +33,10 @@ using std::pair; using std::sort; using std::vector; +typedef FormCB > base_class; + FormCitation::FormCitation(ControlCitation & c) - : FormBase2(c, _("Citation")) + : base_class(c, _("Citation")) {} @@ -241,7 +245,7 @@ ButtonPolicy::SMInput FormCitation::input(FL_OBJECT * ob, long) ControlCitation::REGEX : ControlCitation::SIMPLE; vector::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; diff --git a/src/frontends/xforms/FormCitation.h b/src/frontends/xforms/FormCitation.h index 59d2e69186..d35c256a15 100644 --- a/src/frontends/xforms/FormCitation.h +++ b/src/frontends/xforms/FormCitation.h @@ -8,7 +8,7 @@ * * ====================================================== * - * Author: Angus Leeming + * \author Angus Leeming */ #ifndef FORMCITATION_H @@ -22,10 +22,10 @@ /** This class provides an XForms implementation of the Citation Dialog. */ -#include "form_citation.h" class ControlCitation; +struct FD_form_citation; -class FormCitation : public FormBase2 { +class FormCitation : public FormCB > { public: /// FormCitation(ControlCitation &); diff --git a/src/frontends/xforms/FormLog.C b/src/frontends/xforms/FormLog.C index 4baadfc0ce..194fc2a96e 100644 --- a/src/frontends/xforms/FormLog.C +++ b/src/frontends/xforms/FormLog.C @@ -3,54 +3,38 @@ * John Levon, moz@compsoc.man.ac.uk */ -#include - -#include FORMS_H_LOCATION - #ifdef __GNUG__ #pragma implementation #endif -#include "gettext.h" +#include +#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(c, _("LaTeX Log")) +{} void FormLog::update() { - if (!dialog_.get() || !lv_->view()->available()) - return; - - std::pair 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")); } diff --git a/src/frontends/xforms/FormLog.h b/src/frontends/xforms/FormLog.h index ed82c8e062..220dd3d03a 100644 --- a/src/frontends/xforms/FormLog.h +++ b/src/frontends/xforms/FormLog.h @@ -9,27 +9,29 @@ #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 { 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 diff --git a/src/frontends/xforms/FormMathsPanel.C b/src/frontends/xforms/FormMathsPanel.C index 3e7abab884..a1581e7f62 100644 --- a/src/frontends/xforms/FormMathsPanel.C +++ b/src/frontends/xforms/FormMathsPanel.C @@ -23,15 +23,16 @@ #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" diff --git a/src/frontends/xforms/FormVCLog.C b/src/frontends/xforms/FormVCLog.C index 0fd056768c..b58b93ac65 100644 --- a/src/frontends/xforms/FormVCLog.C +++ b/src/frontends/xforms/FormVCLog.C @@ -3,45 +3,28 @@ * John Levon, moz@compsoc.man.ac.uk */ -#include - -#include FORMS_H_LOCATION - #ifdef __GNUG__ #pragma implementation #endif -#include "gettext.h" +#include +#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(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")); } diff --git a/src/frontends/xforms/FormVCLog.h b/src/frontends/xforms/FormVCLog.h index 56df0b2ee5..cca629d009 100644 --- a/src/frontends/xforms/FormVCLog.h +++ b/src/frontends/xforms/FormVCLog.h @@ -9,27 +9,29 @@ #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 { 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 diff --git a/src/frontends/xforms/form_browser.C b/src/frontends/xforms/form_browser.C index c623cea6b5..326e955295 100644 --- a/src/frontends/xforms/form_browser.C +++ b/src/frontends/xforms/form_browser.C @@ -34,7 +34,7 @@ FD_form_browser * FormBrowser::build_browser() } 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))); @@ -42,7 +42,7 @@ FD_form_browser * FormBrowser::build_browser() } 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; diff --git a/src/frontends/xforms/form_browser.h b/src/frontends/xforms/form_browser.h index e2c80a3e19..a4f3a3d134 100644 --- a/src/frontends/xforms/form_browser.h +++ b/src/frontends/xforms/form_browser.h @@ -5,8 +5,8 @@ #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 ****/ diff --git a/src/frontends/xforms/forms/form_browser.fd b/src/frontends/xforms/forms/form_browser.fd index 9a565286a6..30777451c0 100644 --- a/src/frontends/xforms/forms/form_browser.fd +++ b/src/frontends/xforms/forms/form_browser.fd @@ -63,7 +63,7 @@ shortcut: resize: FL_RESIZE_NONE gravity: FL_SouthEast FL_SouthEast name: button_close -callback: C_FormBaseDeprecatedCancelCB +callback: C_FormBaseCancelCB argument: 0 -------------------- @@ -81,7 +81,7 @@ shortcut: resize: FL_RESIZE_NONE gravity: FL_SouthEast FL_SouthEast name: button_update -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseRestoreCB argument: 0 ============================== diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index e64b36c777..2ea7ef90db 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,8 @@ +2001-03-20 Angus Leeming + + * figinset.C (fl_set_preemptive_callback): moved definition outside + of namespace anon. + 2001-03-20 Lars Gullik Bjønnes * insetminipage.C (Read): prepare for reading of minipage arguments. diff --git a/src/insets/figinset.C b/src/insets/figinset.C index b55ff8f04e..125538ba42 100644 --- a/src/insets/figinset.C +++ b/src/insets/figinset.C @@ -85,6 +85,10 @@ extern FL_OBJECT * figinset_canvas; extern char ** environ; // is this only redundtant on linux systems? Lgb. +// xforms doesn't define this (but it should be in ). +extern "C" +FL_APPEVENT_CB fl_set_preemptive_callback(Window, FL_APPEVENT_CB, void *); + namespace { float const DEG2PI = 57.295779513; @@ -374,12 +378,6 @@ void AllocGrays(int num) 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