2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 2001 The LyX Team.
9 * ======================================================
11 * \file ControlCommand.C
12 * \author Angus Leeming <a.leeming@ic.ac.uk>
16 #pragma implementation
21 #include "ControlCommand.h"
22 #include "BufferView.h"
26 #include "support/LAssert.h"
28 ControlCommand::ControlCommand(LyXView & lv, Dialogs & d, kb_action ac)
29 : ControlInset<InsetCommand>(lv, d),
30 params_(0), action_(ac)
34 void ControlCommand::showInset(InsetCommand * inset)
36 if (inset == 0) return; // maybe we should Assert this?
39 show(inset->params());
43 void ControlCommand::createInset(string const & arg)
48 bc().valid(); // so that the user can press Ok
50 InsetCommandParams params;
51 params.setFromString(arg);
56 void ControlCommand::update()
58 if (params_) delete params_;
61 params_ = new InsetCommandParams(inset_->params());
63 params_ = new InsetCommandParams;
65 bc().readOnly(isReadonly());
70 void ControlCommand::show(InsetCommandParams const & params)
72 if (params_) delete params_;
73 params_ = new InsetCommandParams(params);
75 bc().readOnly(isReadonly());
80 void ControlCommand::hide()
93 InsetCommandParams & ControlCommand::params() const
100 void ControlCommand::apply()
105 // Only update if contents have changed
106 if (params() != inset_->params()) {
107 inset_->setParams(params());
108 lv_.view()->updateInset(inset_, true);
110 } else if (action_ != LFUN_NOACTION){
111 lv_.getLyXFunc()->Dispatch(action_, params().getAsString());