mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-14 06:57:01 +00:00
extended ButtonController so that only FL_OBJECT *s in a trigger_change_
vector can actually cause the Ok, Apply buttons to change state on input. Vector created for FormCitation. Please test! git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1514 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
debcb43788
commit
99a8f84465
@ -11,11 +11,14 @@
|
|||||||
#include "gettext.h" // _()
|
#include "gettext.h" // _()
|
||||||
//#include "debug.h"
|
//#include "debug.h"
|
||||||
|
|
||||||
|
using std::find;
|
||||||
|
using std::vector;
|
||||||
|
|
||||||
ButtonController::ButtonController(ButtonPolicy * bp,
|
ButtonController::ButtonController(ButtonPolicy * bp,
|
||||||
char const * cancel, char const * close)
|
char const * cancel, char const * close)
|
||||||
: bp_(bp), okay_(0), apply_(0), cancel_(0), undo_all_(0),
|
: bp_(bp), okay_(0), apply_(0), cancel_(0), undo_all_(0),
|
||||||
read_only_(), cancel_label(cancel), close_label(close)
|
read_only_(), trigger_change_(),
|
||||||
|
cancel_label(cancel), close_label(close)
|
||||||
{
|
{
|
||||||
Assert(bp);
|
Assert(bp);
|
||||||
}
|
}
|
||||||
@ -143,13 +146,29 @@ void ButtonController::readWrite()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ButtonController::valid(bool v)
|
bool ButtonController::valid(bool v, FL_OBJECT * obj)
|
||||||
{
|
{
|
||||||
|
if (obj && !trigger_change_.empty()) {
|
||||||
|
vector<FL_OBJECT *>::const_iterator cit =
|
||||||
|
find(trigger_change_.begin(), trigger_change_.end(),
|
||||||
|
obj);
|
||||||
|
|
||||||
|
// Only trigger a change if the obj is in the list
|
||||||
|
if (cit != trigger_change_.end()) {
|
||||||
if (v) {
|
if (v) {
|
||||||
input(ButtonPolicy::SMI_VALID);
|
input(ButtonPolicy::SMI_VALID);
|
||||||
} else {
|
} else {
|
||||||
input(ButtonPolicy::SMI_INVALID);
|
input(ButtonPolicy::SMI_INVALID);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (v) {
|
||||||
|
input(ButtonPolicy::SMI_VALID);
|
||||||
|
} else {
|
||||||
|
input(ButtonPolicy::SMI_INVALID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,6 +89,15 @@ public:
|
|||||||
read_only_.erase(read_only_.begin(), read_only_.end());
|
read_only_.erase(read_only_.begin(), read_only_.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
void addTriggerChange(FL_OBJECT * obj) {
|
||||||
|
trigger_change_.push_back(obj);
|
||||||
|
}
|
||||||
|
///
|
||||||
|
void eraseTriggerChange() {
|
||||||
|
trigger_change_.clear();
|
||||||
|
}
|
||||||
|
|
||||||
/* Action Functions */
|
/* Action Functions */
|
||||||
/// force a refresh of the buttons
|
/// force a refresh of the buttons
|
||||||
void refresh();
|
void refresh();
|
||||||
@ -110,7 +119,7 @@ public:
|
|||||||
///
|
///
|
||||||
void readWrite();
|
void readWrite();
|
||||||
/// Passthrough function -- returns its input value
|
/// Passthrough function -- returns its input value
|
||||||
bool valid(bool v = true);
|
bool valid(bool v = true, FL_OBJECT * obj = 0);
|
||||||
///
|
///
|
||||||
void invalid();
|
void invalid();
|
||||||
private:
|
private:
|
||||||
@ -126,6 +135,8 @@ private:
|
|||||||
FL_OBJECT * undo_all_;
|
FL_OBJECT * undo_all_;
|
||||||
/// List of items to be deactivated when in one of the read-only states
|
/// List of items to be deactivated when in one of the read-only states
|
||||||
std::list<FL_OBJECT *> read_only_;
|
std::list<FL_OBJECT *> read_only_;
|
||||||
|
/// List of items that will trigger a change in activation status.
|
||||||
|
std::vector<FL_OBJECT *> trigger_change_;
|
||||||
///
|
///
|
||||||
char const * cancel_label;
|
char const * cancel_label;
|
||||||
///
|
///
|
||||||
|
@ -1,3 +1,21 @@
|
|||||||
|
2001-02-14 Angus Leeming <a.leeming@ic.ac.uk>
|
||||||
|
|
||||||
|
* ButtonController.[Ch] (addTriggerChange, eraseTriggerChange):
|
||||||
|
new methods.
|
||||||
|
(valid): method can now be passed an optional FL_OBJECT *. If it is, and
|
||||||
|
the vector of FL_OBJECT *s that can trigger a change in the button state
|
||||||
|
is not empty, then a change of state will occur only if the FL_OBJECT *
|
||||||
|
is present in this vector.
|
||||||
|
|
||||||
|
* FormBase.C (RestoreCB): call bc.undoAll() before restore(). Allows
|
||||||
|
the user to deactivate specific fields within restore().
|
||||||
|
(InputCB): pass the FL_OBJECT * to bc_.valid().
|
||||||
|
|
||||||
|
* FormCitation.C (build): create a vector of FL_OBJECT *s that can
|
||||||
|
trigger a change of state in the Ok,Apply buttons.
|
||||||
|
(update): bc_.readOnly() to the start of the method. Similar reasoning
|
||||||
|
to that for FormBase::RestoreCB, above.
|
||||||
|
|
||||||
2001-02-14 Angus Leeming <a.leeming@ic.ac.uk>
|
2001-02-14 Angus Leeming <a.leeming@ic.ac.uk>
|
||||||
|
|
||||||
* FormBrowser.C: used OkCancelPolicy for ButtonController rather than
|
* FormBrowser.C: used OkCancelPolicy for ButtonController rather than
|
||||||
|
@ -170,7 +170,7 @@ void FormBase::InputCB(FL_OBJECT * ob, long data)
|
|||||||
Assert(ob && ob->form);
|
Assert(ob && ob->form);
|
||||||
FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
|
FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
|
||||||
Assert(ob);
|
Assert(ob);
|
||||||
pre->bc_.valid(pre->input(ob, data));
|
pre->bc_.valid(pre->input(ob, data), ob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -179,8 +179,8 @@ void FormBase::RestoreCB(FL_OBJECT * ob, long)
|
|||||||
Assert(ob && ob->form);
|
Assert(ob && ob->form);
|
||||||
FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
|
FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
|
||||||
Assert(ob);
|
Assert(ob);
|
||||||
pre->restore();
|
|
||||||
pre->bc_.undoAll();
|
pre->bc_.undoAll();
|
||||||
|
pre->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -96,11 +96,20 @@ void FormCitation::build()
|
|||||||
bc_.addReadOnly(dialog_->downBtn);
|
bc_.addReadOnly(dialog_->downBtn);
|
||||||
bc_.addReadOnly(dialog_->textBefore);
|
bc_.addReadOnly(dialog_->textBefore);
|
||||||
bc_.addReadOnly(dialog_->textAftr);
|
bc_.addReadOnly(dialog_->textAftr);
|
||||||
|
|
||||||
|
bc_.addTriggerChange(dialog_->addBtn);
|
||||||
|
bc_.addTriggerChange(dialog_->delBtn);
|
||||||
|
bc_.addTriggerChange(dialog_->upBtn);
|
||||||
|
bc_.addTriggerChange(dialog_->downBtn);
|
||||||
|
bc_.addTriggerChange(dialog_->textBefore);
|
||||||
|
bc_.addTriggerChange(dialog_->textAftr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FormCitation::update()
|
void FormCitation::update()
|
||||||
{
|
{
|
||||||
|
bc_.readOnly(lv_->buffer()->isReadonly());
|
||||||
|
|
||||||
bibkeys.clear();
|
bibkeys.clear();
|
||||||
bibkeysInfo.clear();
|
bibkeysInfo.clear();
|
||||||
|
|
||||||
@ -141,8 +150,6 @@ void FormCitation::update()
|
|||||||
setSize( size, bibPresent );
|
setSize( size, bibPresent );
|
||||||
|
|
||||||
fl_set_input( dialog_->textAftr, params.getOptions().c_str());
|
fl_set_input( dialog_->textAftr, params.getOptions().c_str());
|
||||||
|
|
||||||
bc_.readOnly(lv_->buffer()->isReadonly());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user