mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-11 05:33:33 +00:00
controller-view split of FormLog and FormVCLog.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1796 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
fc8465aa1f
commit
9f29ab3aa5
@ -1,548 +0,0 @@
|
|||||||
// -*- 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");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,471 +0,0 @@
|
|||||||
// -*- 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
|
|
@ -1,3 +1,8 @@
|
|||||||
|
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>
|
2001-03-16 Juergen Vigna <jug@sad.it>
|
||||||
|
|
||||||
* Dialogs.h (noncopyable): added minipage signals.
|
* Dialogs.h (noncopyable): added minipage signals.
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
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>
|
2001-03-19 Angus Leeming <a.leeming@ic.ac.uk>
|
||||||
|
|
||||||
* ControlBibtex.[Ch]: new files; controller for an InsetBibtex popup.
|
* ControlBibtex.[Ch]: new files; controller for an InsetBibtex popup.
|
||||||
|
@ -4,11 +4,12 @@
|
|||||||
*
|
*
|
||||||
* LyX, The Document Processor
|
* LyX, The Document Processor
|
||||||
*
|
*
|
||||||
* Copyright 2000 The LyX Team.
|
* Copyright 2001 The LyX Team.
|
||||||
*
|
*
|
||||||
* ======================================================
|
* ======================================================
|
||||||
*
|
*
|
||||||
* \file ControlBibitem.C
|
* \file ControlBibitem.C
|
||||||
|
* \author John Levon, moz@compsoc.man.ac.uk
|
||||||
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -4,11 +4,12 @@
|
|||||||
*
|
*
|
||||||
* LyX, The Document Processor
|
* LyX, The Document Processor
|
||||||
*
|
*
|
||||||
* Copyright 2000 The LyX Team.
|
* Copyright 2001 The LyX Team.
|
||||||
*
|
*
|
||||||
* ======================================================
|
* ======================================================
|
||||||
*
|
*
|
||||||
* \file ControlBibitem.h
|
* \file ControlBibitem.h
|
||||||
|
* \author John Levon, moz@compsoc.man.ac.uk
|
||||||
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -4,11 +4,12 @@
|
|||||||
*
|
*
|
||||||
* LyX, The Document Processor
|
* LyX, The Document Processor
|
||||||
*
|
*
|
||||||
* Copyright 2000 The LyX Team.
|
* Copyright 2001 The LyX Team.
|
||||||
*
|
*
|
||||||
* ======================================================
|
* ======================================================
|
||||||
*
|
*
|
||||||
* \file ControlBibtex.C
|
* \file ControlBibtex.C
|
||||||
|
* \author John Levon, moz@compsoc.man.ac.uk
|
||||||
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -4,11 +4,12 @@
|
|||||||
*
|
*
|
||||||
* LyX, The Document Processor
|
* LyX, The Document Processor
|
||||||
*
|
*
|
||||||
* Copyright 2000 The LyX Team.
|
* Copyright 2001 The LyX Team.
|
||||||
*
|
*
|
||||||
* ======================================================
|
* ======================================================
|
||||||
*
|
*
|
||||||
* \file ControlBibtex.h
|
* \file ControlBibtex.h
|
||||||
|
* \author John Levon, moz@compsoc.man.ac.uk
|
||||||
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* LyX, The Document Processor
|
* LyX, The Document Processor
|
||||||
*
|
*
|
||||||
* Copyright 2000 The LyX Team.
|
* Copyright 2001 The LyX Team.
|
||||||
*
|
*
|
||||||
* ======================================================
|
* ======================================================
|
||||||
*
|
*
|
||||||
|
66
src/frontends/controllers/ControlLog.C
Normal file
66
src/frontends/controllers/ControlLog.C
Normal file
@ -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 <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();
|
||||||
|
}
|
80
src/frontends/controllers/ControlLog.h
Normal file
80
src/frontends/controllers/ControlLog.h
Normal file
@ -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 <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
|
68
src/frontends/controllers/ControlVCLog.C
Normal file
68
src/frontends/controllers/ControlVCLog.C
Normal file
@ -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 <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();
|
||||||
|
}
|
78
src/frontends/controllers/ControlVCLog.h
Normal file
78
src/frontends/controllers/ControlVCLog.h
Normal file
@ -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 <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
|
@ -26,6 +26,10 @@ libcontrollers_la_SOURCES=\
|
|||||||
ControlCommand.h \
|
ControlCommand.h \
|
||||||
ControlConnections.C \
|
ControlConnections.C \
|
||||||
ControlConnections.h \
|
ControlConnections.h \
|
||||||
|
ControlLog.C \
|
||||||
|
ControlLog.h \
|
||||||
|
ControlVCLog.C \
|
||||||
|
ControlVCLog.h \
|
||||||
ViewBase.h
|
ViewBase.h
|
||||||
|
|
||||||
# just copied from old lyx repository
|
# just copied from old lyx repository
|
||||||
|
@ -1,3 +1,28 @@
|
|||||||
|
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>
|
2001-03-19 Angus Leeming <a.leeming@ic.ac.uk>
|
||||||
|
|
||||||
* FormBibtex.[Ch]:
|
* FormBibtex.[Ch]:
|
||||||
|
@ -20,11 +20,21 @@
|
|||||||
#include "ControlBibitem.h"
|
#include "ControlBibitem.h"
|
||||||
#include "ControlBibtex.h"
|
#include "ControlBibtex.h"
|
||||||
#include "ControlCitation.h"
|
#include "ControlCitation.h"
|
||||||
|
#include "ControlLog.h"
|
||||||
|
#include "ControlVCLog.h"
|
||||||
#include "xformsBC.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 "FormBibitem.h"
|
||||||
#include "FormBibtex.h"
|
#include "FormBibtex.h"
|
||||||
#include "FormCitation.h"
|
#include "FormCitation.h"
|
||||||
|
#include "FormLog.h"
|
||||||
|
#include "FormVCLog.h"
|
||||||
|
|
||||||
#include "FormCharacter.h"
|
#include "FormCharacter.h"
|
||||||
#include "FormCopyright.h"
|
#include "FormCopyright.h"
|
||||||
#include "FormCredits.h"
|
#include "FormCredits.h"
|
||||||
@ -34,7 +44,6 @@
|
|||||||
#include "FormGraphics.h"
|
#include "FormGraphics.h"
|
||||||
#include "FormInclude.h"
|
#include "FormInclude.h"
|
||||||
#include "FormIndex.h"
|
#include "FormIndex.h"
|
||||||
#include "FormLog.h"
|
|
||||||
#include "FormMathsPanel.h"
|
#include "FormMathsPanel.h"
|
||||||
#include "FormParagraph.h"
|
#include "FormParagraph.h"
|
||||||
#include "FormPreamble.h"
|
#include "FormPreamble.h"
|
||||||
@ -47,7 +56,6 @@
|
|||||||
#include "FormTabularCreate.h"
|
#include "FormTabularCreate.h"
|
||||||
#include "FormToc.h"
|
#include "FormToc.h"
|
||||||
#include "FormUrl.h"
|
#include "FormUrl.h"
|
||||||
#include "FormVCLog.h"
|
|
||||||
#include "FormMinipage.h"
|
#include "FormMinipage.h"
|
||||||
|
|
||||||
// Signal enabling all visible popups to be redrawn if so desired.
|
// Signal enabling all visible popups to be redrawn if so desired.
|
||||||
@ -61,6 +69,8 @@ Dialogs::Dialogs(LyXView * lv)
|
|||||||
add(new GUICitation<FormCitation, xformsBC>(*lv, *this));
|
add(new GUICitation<FormCitation, xformsBC>(*lv, *this));
|
||||||
add(new GUIBibitem<FormBibitem, xformsBC>(*lv, *this));
|
add(new GUIBibitem<FormBibitem, xformsBC>(*lv, *this));
|
||||||
add(new GUIBibtex<FormBibtex, 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 FormCharacter(lv, this));
|
||||||
add(new FormCopyright(lv, this));
|
add(new FormCopyright(lv, this));
|
||||||
@ -71,7 +81,6 @@ Dialogs::Dialogs(LyXView * lv)
|
|||||||
add(new FormGraphics(lv, this));
|
add(new FormGraphics(lv, this));
|
||||||
add(new FormInclude(lv, this));
|
add(new FormInclude(lv, this));
|
||||||
add(new FormIndex(lv, this));
|
add(new FormIndex(lv, this));
|
||||||
add(new FormLog(lv, this));
|
|
||||||
add(new FormMathsPanel(lv, this));
|
add(new FormMathsPanel(lv, this));
|
||||||
add(new FormParagraph(lv, this));
|
add(new FormParagraph(lv, this));
|
||||||
add(new FormPreamble(lv, this));
|
add(new FormPreamble(lv, this));
|
||||||
@ -84,7 +93,6 @@ Dialogs::Dialogs(LyXView * lv)
|
|||||||
add(new FormTabularCreate(lv, this));
|
add(new FormTabularCreate(lv, this));
|
||||||
add(new FormToc(lv, this));
|
add(new FormToc(lv, this));
|
||||||
add(new FormUrl(lv, this));
|
add(new FormUrl(lv, this));
|
||||||
add(new FormVCLog(lv, this));
|
|
||||||
add(new FormMinipage(lv, this));
|
add(new FormMinipage(lv, this));
|
||||||
|
|
||||||
// reduce the number of connections needed in
|
// reduce the number of connections needed in
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
* Copyright 2000 The LyX Team.
|
* Copyright 2000 The LyX Team.
|
||||||
*
|
*
|
||||||
* ======================================================
|
* ======================================================
|
||||||
|
*
|
||||||
|
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
@ -87,6 +89,12 @@ void FormBase::InputCB(FL_OBJECT * ob, long data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ButtonPolicy::SMInput FormBase::input(FL_OBJECT *, long)
|
||||||
|
{
|
||||||
|
return ButtonPolicy::SMI_NOOP;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
FormBase * GetForm(FL_OBJECT * ob)
|
FormBase * GetForm(FL_OBJECT * ob)
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
* ======================================================
|
* ======================================================
|
||||||
*
|
*
|
||||||
* Author: Angus Leeming <a.leeming@ic.ac.uk>
|
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef FORMBASE_H
|
#ifndef FORMBASE_H
|
||||||
@ -53,7 +53,7 @@ private:
|
|||||||
virtual FL_FORM * form() const = 0;
|
virtual FL_FORM * form() const = 0;
|
||||||
/** Filter the inputs on callback from xforms
|
/** Filter the inputs on callback from xforms
|
||||||
Return true if inputs are valid. */
|
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,
|
/** Redraw the form (on receipt of a Signal indicating, for example,
|
||||||
that the xform colors have been re-mapped). */
|
that the xform colors have been re-mapped). */
|
||||||
@ -71,14 +71,12 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <class Controller, class Dialog>
|
template <class Dialog>
|
||||||
class FormBase2: public FormBase
|
class FormDB: public FormBase
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
///
|
///
|
||||||
FormBase2(ControlBase &, string const &);
|
FormDB(ControlBase &, string const &);
|
||||||
/// The parent controller
|
|
||||||
Controller & controller() const;
|
|
||||||
/// Pointer to the actual instantiation of xform's form
|
/// Pointer to the actual instantiation of xform's form
|
||||||
virtual FL_FORM * form() const;
|
virtual FL_FORM * form() const;
|
||||||
/// Real GUI implementation.
|
/// Real GUI implementation.
|
||||||
@ -86,26 +84,43 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <class Controller, class Dialog>
|
template <class Dialog>
|
||||||
FormBase2<Controller, Dialog>::FormBase2(ControlBase & c, string const & t)
|
FormDB<Dialog>::FormDB(ControlBase & c, string const & t)
|
||||||
: FormBase(c, t)
|
: FormBase(c, t)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
template <class Controller, class Dialog>
|
template <class Dialog>
|
||||||
Controller & FormBase2<Controller, Dialog>::controller() const
|
FL_FORM * FormDB<Dialog>::form() const
|
||||||
{
|
|
||||||
return static_cast<Controller &>(controller_);
|
|
||||||
//return dynamic_cast<Controller &>(controller_);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template <class Controller, class Dialog>
|
|
||||||
FL_FORM * FormBase2<Controller, Dialog>::form() const
|
|
||||||
{
|
{
|
||||||
if (dialog_.get()) return dialog_->form;
|
if (dialog_.get()) return dialog_->form;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class Controller, class Base>
|
||||||
|
class FormCB: public Base
|
||||||
|
{
|
||||||
|
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_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // FORMBASE_H
|
#endif // FORMBASE_H
|
||||||
|
@ -14,12 +14,15 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include "ControlBibitem.h"
|
#include "ControlBibitem.h"
|
||||||
#include "FormBibitem.h"
|
#include "FormBibitem.h"
|
||||||
|
#include "form_bibitem.h"
|
||||||
#include "gettext.h"
|
#include "gettext.h"
|
||||||
#include "xformsBC.h"
|
#include "xformsBC.h"
|
||||||
#include "support/lstrings.h" // compare
|
#include "support/lstrings.h" // compare
|
||||||
|
|
||||||
|
typedef FormCB<ControlBibitem, FormDB<FD_form_bibitem> > base_class;
|
||||||
|
|
||||||
FormBibitem::FormBibitem(ControlBibitem & c)
|
FormBibitem::FormBibitem(ControlBibitem & c)
|
||||||
: FormBase2<ControlBibitem, FD_form_bibitem>(c, _("Bibliography Entry"))
|
: base_class(c, _("Bibliography Entry"))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
* Copyright 2001 the LyX Team
|
* Copyright 2001 the LyX Team
|
||||||
* Read the file COPYING
|
* Read the file COPYING
|
||||||
*
|
*
|
||||||
* \author Angus Leeming
|
* \author John Levon, moz@compsoc.man.ac.uk
|
||||||
* \author John Levon
|
* \author Angus Leeming, a.leeming@.ac.uk
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef FORMBIBITEM_H
|
#ifndef FORMBIBITEM_H
|
||||||
@ -17,14 +17,13 @@
|
|||||||
|
|
||||||
#include "FormBase.h"
|
#include "FormBase.h"
|
||||||
|
|
||||||
#include "form_bibitem.h"
|
|
||||||
|
|
||||||
class ControlBibitem;
|
class ControlBibitem;
|
||||||
|
struct FD_form_bibitem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For bibliography entry editing
|
* For bibliography entry editing
|
||||||
*/
|
*/
|
||||||
class FormBibitem : public FormBase2<ControlBibitem, FD_form_bibitem> {
|
class FormBibitem : public FormCB<ControlBibitem, FormDB<FD_form_bibitem> > {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
FormBibitem(ControlBibitem &);
|
FormBibitem(ControlBibitem &);
|
||||||
|
@ -14,12 +14,15 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include "ControlBibtex.h"
|
#include "ControlBibtex.h"
|
||||||
#include "FormBibtex.h"
|
#include "FormBibtex.h"
|
||||||
|
#include "form_bibtex.h"
|
||||||
#include "gettext.h"
|
#include "gettext.h"
|
||||||
#include "xformsBC.h"
|
#include "xformsBC.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
|
typedef FormCB<ControlBibtex, FormDB<FD_form_bibtex> > base_class;
|
||||||
|
|
||||||
FormBibtex::FormBibtex(ControlBibtex & c)
|
FormBibtex::FormBibtex(ControlBibtex & c)
|
||||||
: FormBase2<ControlBibtex, FD_form_bibtex>(c, _("BibTeX Database"))
|
: base_class(c, _("BibTeX Database"))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,14 +17,13 @@
|
|||||||
|
|
||||||
#include "FormBase.h"
|
#include "FormBase.h"
|
||||||
|
|
||||||
#include "form_bibtex.h"
|
|
||||||
|
|
||||||
class ControlBibtex;
|
class ControlBibtex;
|
||||||
|
struct FD_form_bibtex;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For bibtex database setting
|
* For bibtex database setting
|
||||||
*/
|
*/
|
||||||
class FormBibtex : public FormBase2<ControlBibtex, FD_form_bibtex> {
|
class FormBibtex : public FormCB<ControlBibtex, FormDB<FD_form_bibtex> > {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
FormBibtex(ControlBibtex &);
|
FormBibtex(ControlBibtex &);
|
||||||
|
@ -3,24 +3,17 @@
|
|||||||
* John Levon, moz@compsoc.man.ac.uk
|
* John Levon, moz@compsoc.man.ac.uk
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
|
||||||
|
|
||||||
#include FORMS_H_LOCATION
|
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma implementation
|
#pragma implementation
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "gettext.h"
|
#include <config.h>
|
||||||
#include "FormBrowser.h"
|
#include "FormBrowser.h"
|
||||||
#include "form_browser.h"
|
#include "form_browser.h"
|
||||||
#include "LyXView.h"
|
#include "xformsBC.h"
|
||||||
#include "Dialogs.h"
|
|
||||||
#include "lyxrc.h"
|
|
||||||
#include "buffer.h"
|
|
||||||
|
|
||||||
FormBrowser::FormBrowser(LyXView * lv, Dialogs * d, const string & name)
|
FormBrowser::FormBrowser(ControlBase & c, string const & t)
|
||||||
: FormBaseBD(lv, d, name)
|
: FormDB<FD_form_browser>(c, t)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -32,21 +25,3 @@ void FormBrowser::build()
|
|||||||
bc().setCancel(dialog_->button_close);
|
bc().setCancel(dialog_->button_close);
|
||||||
bc().refresh();
|
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;
|
|
||||||
}
|
|
||||||
|
@ -1,58 +1,37 @@
|
|||||||
// -*- C++ -*-
|
// -*- C++ -*-
|
||||||
/*
|
/*
|
||||||
* FormBrowser.h
|
* \file FormBrowser.h
|
||||||
*
|
*
|
||||||
* (C) 2001 LyX Team
|
* (C) 2001 LyX Team
|
||||||
* John Levon, moz@compsoc.man.ac.uk
|
* John Levon, moz@compsoc.man.ac.uk
|
||||||
|
* \author Angus Leeming, a.leeming@.ac.uk
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef FORMBROWSER_H
|
#ifndef FORMBROWSER_H
|
||||||
#define FORMBROWSER_H
|
#define FORMBROWSER_H
|
||||||
|
|
||||||
#include <boost/smart_ptr.hpp>
|
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma interface
|
#pragma interface
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "FormBaseDeprecated.h"
|
#include "FormBase.h"
|
||||||
|
|
||||||
struct FD_form_browser;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides an XForms implementation of a read only
|
* This class provides an XForms implementation of a read only
|
||||||
* text browser.
|
* text browser.
|
||||||
*/
|
*/
|
||||||
class FormBrowser : public FormBaseBD {
|
struct FD_form_browser;
|
||||||
|
|
||||||
|
class FormBrowser : public FormDB<FD_form_browser> {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
FormBrowser(LyXView *, Dialogs *, const string &);
|
FormBrowser(ControlBase &, string const &);
|
||||||
protected:
|
|
||||||
/// Update the dialog.
|
|
||||||
virtual void update();
|
|
||||||
|
|
||||||
/// Real GUI implementation.
|
|
||||||
boost::scoped_ptr<FD_form_browser> dialog_;
|
|
||||||
/// Pointer to the actual instantiation of the ButtonController.
|
|
||||||
virtual xformsBC & bc();
|
|
||||||
private:
|
private:
|
||||||
/// Pointer to the actual instantiation of the xforms form
|
/// Build the dialog.
|
||||||
virtual FL_FORM * form() const;
|
|
||||||
/// Filter the inputs on callback from xforms
|
|
||||||
virtual bool input(FL_OBJECT *, long);
|
|
||||||
/// Build the dialog
|
|
||||||
virtual void build();
|
virtual void build();
|
||||||
|
|
||||||
/// generated build function
|
/// generated build function
|
||||||
FD_form_browser * build_browser();
|
FD_form_browser * build_browser();
|
||||||
/// The ButtonController
|
|
||||||
ButtonController<OkCancelPolicy, xformsBC> bc_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif // FORMBROWSER_H
|
||||||
inline
|
|
||||||
xformsBC & FormBrowser::bc()
|
|
||||||
{
|
|
||||||
return bc_;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
* Copyright 2000 The LyX Team.
|
* Copyright 2000 The LyX Team.
|
||||||
*
|
*
|
||||||
* ======================================================
|
* ======================================================
|
||||||
|
*
|
||||||
|
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@ -31,8 +33,10 @@ using std::pair;
|
|||||||
using std::sort;
|
using std::sort;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
|
typedef FormCB<ControlCitation, FormDB<FD_form_citation> > base_class;
|
||||||
|
|
||||||
FormCitation::FormCitation(ControlCitation & c)
|
FormCitation::FormCitation(ControlCitation & c)
|
||||||
: FormBase2<ControlCitation, FD_form_citation>(c, _("Citation"))
|
: base_class(c, _("Citation"))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -241,7 +245,7 @@ ButtonPolicy::SMInput FormCitation::input(FL_OBJECT * ob, long)
|
|||||||
ControlCitation::REGEX : ControlCitation::SIMPLE;
|
ControlCitation::REGEX : ControlCitation::SIMPLE;
|
||||||
|
|
||||||
vector<string>::const_iterator start = bibkeys.begin();
|
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())
|
if (sel >= 1 && sel <= bibkeys.size())
|
||||||
start += sel-1;
|
start += sel-1;
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
* ======================================================
|
* ======================================================
|
||||||
*
|
*
|
||||||
* Author: Angus Leeming <a.leeming@ic.ac.uk>
|
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef FORMCITATION_H
|
#ifndef FORMCITATION_H
|
||||||
@ -22,10 +22,10 @@
|
|||||||
|
|
||||||
/** This class provides an XForms implementation of the Citation Dialog.
|
/** This class provides an XForms implementation of the Citation Dialog.
|
||||||
*/
|
*/
|
||||||
#include "form_citation.h"
|
|
||||||
class ControlCitation;
|
class ControlCitation;
|
||||||
|
struct FD_form_citation;
|
||||||
|
|
||||||
class FormCitation : public FormBase2<ControlCitation, FD_form_citation> {
|
class FormCitation : public FormCB<ControlCitation, FormDB<FD_form_citation> > {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
FormCitation(ControlCitation &);
|
FormCitation(ControlCitation &);
|
||||||
|
@ -3,54 +3,38 @@
|
|||||||
* John Levon, moz@compsoc.man.ac.uk
|
* John Levon, moz@compsoc.man.ac.uk
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
|
||||||
|
|
||||||
#include FORMS_H_LOCATION
|
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma implementation
|
#pragma implementation
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "gettext.h"
|
#include <config.h>
|
||||||
|
#include "xformsBC.h"
|
||||||
|
#include "ControlLog.h"
|
||||||
#include "FormLog.h"
|
#include "FormLog.h"
|
||||||
#include "form_browser.h"
|
#include "form_browser.h"
|
||||||
#include "LyXView.h"
|
#include "gettext.h"
|
||||||
#include "Dialogs.h"
|
|
||||||
#include "lyxrc.h"
|
|
||||||
#include "buffer.h"
|
|
||||||
|
|
||||||
using SigC::slot;
|
FormLog::FormLog(ControlLog & c)
|
||||||
|
: FormCB<ControlLog, FormBrowser>(c, _("LaTeX Log"))
|
||||||
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void FormLog::update()
|
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);
|
fl_clear_browser(dialog_->browser);
|
||||||
|
|
||||||
if (logfile.first == Buffer::buildlog) {
|
if (controller().logfile().first == Buffer::buildlog) {
|
||||||
fl_set_form_title(dialog_->form, _("Build log"));
|
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,
|
fl_add_browser_line(dialog_->browser,
|
||||||
_("No build log file found"));
|
_("No build log file found"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fl_set_form_title(dialog_->form, _("LaTeX Log"));
|
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,
|
fl_add_browser_line(dialog_->browser,
|
||||||
_("No LaTeX log file found"));
|
_("No LaTeX log file found"));
|
||||||
}
|
}
|
||||||
|
@ -9,27 +9,29 @@
|
|||||||
#ifndef FORMLOG_H
|
#ifndef FORMLOG_H
|
||||||
#define FORMLOG_H
|
#define FORMLOG_H
|
||||||
|
|
||||||
#include "FormBaseDeprecated.h"
|
|
||||||
#include "FormBrowser.h"
|
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma interface
|
#pragma interface
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class LyXView;
|
#include "FormBrowser.h"
|
||||||
class Dialogs;
|
|
||||||
|
class ControlLog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides an XForms implementation of the LaTeX log dialog
|
* This class provides an XForms implementation of the LaTeX log dialog
|
||||||
* for viewing the last LaTeX log file.
|
* for viewing the last LaTeX log file.
|
||||||
*/
|
*/
|
||||||
class FormLog : public FormBrowser {
|
class FormLog : public FormCB<ControlLog, FormBrowser> {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
FormLog(LyXView *, Dialogs *);
|
FormLog(ControlLog &);
|
||||||
private:
|
|
||||||
/// Update the dialog.
|
// Functions accessible to the Controller.
|
||||||
|
|
||||||
|
/// Set the Params variable for the Controller.
|
||||||
|
virtual void apply() {}
|
||||||
|
/// Update dialog before/whilst showing it.
|
||||||
virtual void update();
|
virtual void update();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // FORMLOG_H
|
||||||
|
@ -23,15 +23,16 @@
|
|||||||
#include "MathsSymbols.h"
|
#include "MathsSymbols.h"
|
||||||
#include "debug.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 "FormMathsBitmap.h"
|
||||||
#include "FormMathsDeco.h"
|
#include "FormMathsDeco.h"
|
||||||
#include "form_maths_deco.h"
|
|
||||||
#include "FormMathsDelim.h"
|
#include "FormMathsDelim.h"
|
||||||
#include "form_maths_delim.h"
|
|
||||||
#include "FormMathsMatrix.h"
|
#include "FormMathsMatrix.h"
|
||||||
#include "form_maths_matrix.h"
|
|
||||||
#include "FormMathsSpace.h"
|
#include "FormMathsSpace.h"
|
||||||
#include "form_maths_space.h"
|
|
||||||
|
|
||||||
#include "deco.xpm"
|
#include "deco.xpm"
|
||||||
#include "delim.xpm"
|
#include "delim.xpm"
|
||||||
|
@ -3,45 +3,28 @@
|
|||||||
* John Levon, moz@compsoc.man.ac.uk
|
* John Levon, moz@compsoc.man.ac.uk
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
|
||||||
|
|
||||||
#include FORMS_H_LOCATION
|
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma implementation
|
#pragma implementation
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "gettext.h"
|
#include <config.h>
|
||||||
|
#include "xformsBC.h"
|
||||||
|
#include "ControlVCLog.h"
|
||||||
#include "FormVCLog.h"
|
#include "FormVCLog.h"
|
||||||
#include "form_browser.h"
|
#include "form_browser.h"
|
||||||
#include "LyXView.h"
|
#include "gettext.h"
|
||||||
#include "Dialogs.h"
|
|
||||||
#include "lyxrc.h"
|
|
||||||
#include "buffer.h"
|
|
||||||
|
|
||||||
using SigC::slot;
|
FormVCLog::FormVCLog(ControlVCLog & c)
|
||||||
|
: FormCB<ControlVCLog, FormBrowser>(c, _("Version Control Log"))
|
||||||
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void FormVCLog::update()
|
void FormVCLog::update()
|
||||||
{
|
{
|
||||||
if (!dialog_.get() || !lv_->view()->available())
|
|
||||||
return;
|
|
||||||
|
|
||||||
const string logfile = lv_->view()->buffer()->lyxvc.getLogFile();
|
|
||||||
|
|
||||||
fl_clear_browser(dialog_->browser);
|
fl_clear_browser(dialog_->browser);
|
||||||
|
|
||||||
if (logfile=="" || !fl_load_browser(dialog_->browser, logfile.c_str()))
|
if (controller().logfile().empty() ||
|
||||||
fl_add_browser_line(dialog_->browser, _("No version control log file available"));
|
!fl_load_browser(dialog_->browser, controller().logfile().c_str()))
|
||||||
|
fl_add_browser_line(dialog_->browser,
|
||||||
lyx::unlink(logfile);
|
_("No version control log file available"));
|
||||||
}
|
}
|
||||||
|
@ -9,27 +9,29 @@
|
|||||||
#ifndef FORMVCLOG_H
|
#ifndef FORMVCLOG_H
|
||||||
#define FORMVCLOG_H
|
#define FORMVCLOG_H
|
||||||
|
|
||||||
#include "FormBaseDeprecated.h"
|
|
||||||
#include "FormBrowser.h"
|
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma interface
|
#pragma interface
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class LyXView;
|
#include "FormBrowser.h"
|
||||||
class Dialogs;
|
|
||||||
|
class ControlVCLog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides an XForms implementation of the Version Control
|
* This class provides an XForms implementation of the Version Control
|
||||||
* log viewer
|
* log viewer
|
||||||
*/
|
*/
|
||||||
class FormVCLog : public FormBrowser {
|
class FormVCLog : public FormCB<ControlVCLog, FormBrowser> {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
FormVCLog(LyXView *, Dialogs *);
|
FormVCLog(ControlVCLog &);
|
||||||
private:
|
|
||||||
/// Update the dialog.
|
// Functions accessible to the Controller.
|
||||||
|
|
||||||
|
/// Set the Params variable for the Controller.
|
||||||
|
virtual void apply() {}
|
||||||
|
/// Update dialog before/whilst showing it.
|
||||||
virtual void update();
|
virtual void update();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // FORMVCLOG_H
|
||||||
|
@ -34,7 +34,7 @@ FD_form_browser * FormBrowser::build_browser()
|
|||||||
}
|
}
|
||||||
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
|
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
|
||||||
fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
|
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");
|
char const * const dummy = N_("Update|#Uu");
|
||||||
fdui->button_update = obj = fl_add_button(FL_NORMAL_BUTTON, 270, 340, 90, 30, idex(_(dummy)));
|
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_lsize(obj, FL_NORMAL_SIZE);
|
||||||
fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
|
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();
|
fl_end_form();
|
||||||
|
|
||||||
fdui->form->fdui = fdui;
|
fdui->form->fdui = fdui;
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
#define FD_form_browser_h_
|
#define FD_form_browser_h_
|
||||||
|
|
||||||
/** Callbacks, globals and object handlers **/
|
/** Callbacks, globals and object handlers **/
|
||||||
extern "C" void C_FormBaseDeprecatedCancelCB(FL_OBJECT *, long);
|
extern "C" void C_FormBaseCancelCB(FL_OBJECT *, long);
|
||||||
extern "C" void C_FormBaseDeprecatedInputCB(FL_OBJECT *, long);
|
extern "C" void C_FormBaseRestoreCB(FL_OBJECT *, long);
|
||||||
|
|
||||||
|
|
||||||
/**** Forms and Objects ****/
|
/**** Forms and Objects ****/
|
||||||
|
@ -63,7 +63,7 @@ shortcut:
|
|||||||
resize: FL_RESIZE_NONE
|
resize: FL_RESIZE_NONE
|
||||||
gravity: FL_SouthEast FL_SouthEast
|
gravity: FL_SouthEast FL_SouthEast
|
||||||
name: button_close
|
name: button_close
|
||||||
callback: C_FormBaseDeprecatedCancelCB
|
callback: C_FormBaseCancelCB
|
||||||
argument: 0
|
argument: 0
|
||||||
|
|
||||||
--------------------
|
--------------------
|
||||||
@ -81,7 +81,7 @@ shortcut:
|
|||||||
resize: FL_RESIZE_NONE
|
resize: FL_RESIZE_NONE
|
||||||
gravity: FL_SouthEast FL_SouthEast
|
gravity: FL_SouthEast FL_SouthEast
|
||||||
name: button_update
|
name: button_update
|
||||||
callback: C_FormBaseDeprecatedInputCB
|
callback: C_FormBaseRestoreCB
|
||||||
argument: 0
|
argument: 0
|
||||||
|
|
||||||
==============================
|
==============================
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
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>
|
2001-03-20 Lars Gullik Bjønnes <larsbj@trylle.birdstep.com>
|
||||||
|
|
||||||
* insetminipage.C (Read): prepare for reading of minipage arguments.
|
* insetminipage.C (Read): prepare for reading of minipage arguments.
|
||||||
|
@ -85,6 +85,10 @@ extern FL_OBJECT * figinset_canvas;
|
|||||||
|
|
||||||
extern char ** environ; // is this only redundtant on linux systems? Lgb.
|
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 {
|
namespace {
|
||||||
|
|
||||||
float const DEG2PI = 57.295779513;
|
float const DEG2PI = 57.295779513;
|
||||||
@ -374,12 +378,6 @@ void AllocGrays(int num)
|
|||||||
gs_color = true;
|
gs_color = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// xforms doesn't define this
|
|
||||||
extern "C"
|
|
||||||
FL_APPEVENT_CB fl_set_preemptive_callback(Window, FL_APPEVENT_CB, void *);
|
|
||||||
|
|
||||||
|
|
||||||
void InitFigures()
|
void InitFigures()
|
||||||
{
|
{
|
||||||
// if bitmaps and figures are not empty we will leak mem
|
// if bitmaps and figures are not empty we will leak mem
|
||||||
|
Loading…
Reference in New Issue
Block a user