'suffix' is no longer a safe global variable name in scripts;

Drop down list for word lists stay open after clicking on a prefix choice.

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@663 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2007-09-02 18:18:04 +00:00
parent 0157f96f9a
commit 01de02b904
7 changed files with 42 additions and 34 deletions
+1 -24
View File
@@ -22,20 +22,14 @@ class DropDownMultipleChoiceList : public DropDownChoiceListBase {
virtual void onShow();
virtual void select(size_t item);
virtual size_t selection() const;
virtual bool stayOpen() const { return true; }
virtual bool stayOpen(size_t selection) const { return true; }
virtual DropDownList* createSubMenu(ChoiceField::ChoiceP group) const;
virtual void drawIcon(DC& dc, int x, int y, size_t item, bool selected) const;
virtual void onMouseLeave(wxMouseEvent&);
private:
DECLARE_EVENT_TABLE();
bool kept_open; ///< Was the list kept open after selecting a choice, if so, be eager to close it
};
DropDownMultipleChoiceList::DropDownMultipleChoiceList
(Window* parent, bool is_submenu, ValueViewer& cve, ChoiceField::ChoiceP group)
: DropDownChoiceListBase(parent, is_submenu, cve, group)
, kept_open(false)
{
icon_size.width += 16;
}
@@ -50,7 +44,6 @@ void DropDownMultipleChoiceList::select(size_t item) {
}
// keep the box open
DropDownChoiceListBase::onShow(); // update 'enabled'
kept_open = true;
}
void DropDownMultipleChoiceList::drawIcon(DC& dc, int x, int y, size_t item, bool selected) const {
@@ -82,7 +75,6 @@ void DropDownMultipleChoiceList::onShow() {
DropDownChoiceListBase::onShow();
// we need thumbnail images soon
const_cast<DropDownMultipleChoiceList*>(this)->generateThumbnailImages();
kept_open = false;
}
size_t DropDownMultipleChoiceList::selection() const {
@@ -93,21 +85,6 @@ DropDownList* DropDownMultipleChoiceList::createSubMenu(ChoiceField::ChoiceP gro
return new DropDownMultipleChoiceList(const_cast<DropDownMultipleChoiceList*>(this), true, cve, group);
}
void DropDownMultipleChoiceList::onMouseLeave(wxMouseEvent& ev) {
if (kept_open) {
wxSize cs = GetClientSize();
if (ev.GetX() < 0 || ev.GetY() < 0 || ev.GetX() >= cs.x || ev.GetY() >= cs.y) {
hide(false); // outside box; hide it
ev.Skip();
return;
}
}
}
BEGIN_EVENT_TABLE(DropDownMultipleChoiceList, DropDownChoiceListBase)
EVT_LEAVE_WINDOW(DropDownMultipleChoiceList::onMouseLeave)
END_EVENT_TABLE()
// ----------------------------------------------------------------------------- : MultipleChoiceValueEditor
IMPLEMENT_VALUE_EDITOR(MultipleChoice) {}
+9 -1
View File
@@ -131,6 +131,7 @@ class DropDownWordList : public DropDownList {
virtual DropDownList* submenu(size_t item) const;
virtual size_t selection() const;
virtual void select(size_t item);
virtual bool stayOpen(size_t selection) const;
private:
TextValueEditor& tve;
WordListPosP pos;
@@ -280,7 +281,7 @@ void DropDownWordList::select(size_t item) {
// determine new value
String new_value;
bool toggling_prefix = items[item].word->is_prefix;
for (size_t i = 0 ; i < words->words.size() ; ++i) {
for (size_t i = 0 ; i < items.size() ; ++i) {
const DropDownWordListItem& it = items[i];
if (it.word->is_prefix) {
if (it.active() != (i == item)) {
@@ -298,6 +299,13 @@ void DropDownWordList::select(size_t item) {
tve.fixSelection(TYPE_INDEX);
tve.replaceSelection(escape(new_value),
format_string(_ACTION_("change"), tve.field().name));
// stay open?
if (IsShown()) selection(); // update 'enabled'
}
bool DropDownWordList::stayOpen(size_t selection) const {
if (selection == NO_SELECTION) return false;
return items[selection].word->is_prefix;
}
void DropDownWordList::redrawArrowOnParent() {