mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
all card lists share the widths of the columns
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@398 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -28,6 +28,7 @@ DECLARE_TYPEOF_COLLECTION(FieldP);
|
||||
DECLARE_POINTER_TYPE(ChoiceValue);
|
||||
DECLARE_TYPEOF(map<int COMMA FieldP>);
|
||||
DECLARE_TYPEOF_NO_REV(IndexMap<FieldP COMMA StyleP>);
|
||||
DECLARE_TYPEOF_COLLECTION(CardListBase*);
|
||||
|
||||
// ----------------------------------------------------------------------------- : Events
|
||||
|
||||
@@ -35,12 +36,19 @@ DEFINE_EVENT_TYPE(EVENT_CARD_SELECT);
|
||||
|
||||
// ----------------------------------------------------------------------------- : CardListBase
|
||||
|
||||
vector<CardListBase*> CardListBase::card_lists;
|
||||
|
||||
CardListBase::CardListBase(Window* parent, int id, long additional_style)
|
||||
: ItemList(parent, id, additional_style)
|
||||
{}
|
||||
{
|
||||
// add to the list of card lists
|
||||
card_lists.push_back(this);
|
||||
}
|
||||
|
||||
CardListBase::~CardListBase() {
|
||||
storeColumns();
|
||||
// remove from list of card lists
|
||||
card_lists.erase(remove(card_lists.begin(), card_lists.end(), this));
|
||||
}
|
||||
|
||||
void CardListBase::onBeforeChangeSet() {
|
||||
@@ -245,7 +253,12 @@ void CardListBase::storeColumns() {
|
||||
void CardListBase::selectColumns() {
|
||||
CardListColumnSelectDialog wnd(this, set->game);
|
||||
if (wnd.ShowModal() == wxID_OK) {
|
||||
rebuild(); // columns have changed
|
||||
// rebuild all card lists for this game
|
||||
FOR_EACH(card_list, card_lists) {
|
||||
if (card_list->set && card_list->set->game == set->game) {
|
||||
card_list->rebuild();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,6 +294,16 @@ void CardListBase::onColumnRightClick(wxListEvent&) {
|
||||
m->Append(ID_SELECT_COLUMNS, _("&Select Columns..."), _("Select what columns should be shown and in what order."));
|
||||
PopupMenu(m);
|
||||
}
|
||||
void CardListBase::onColumnResize(wxListEvent& ev) {
|
||||
storeColumns();
|
||||
int col = ev.GetColumn();
|
||||
int width = GetColumnWidth(col);
|
||||
FOR_EACH(card_list, card_lists) {
|
||||
if (card_list != this && card_list->set && card_list->set->game == set->game) {
|
||||
card_list->SetColumnWidth(col, width);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CardListBase::onSelectColumns(wxCommandEvent&) {
|
||||
selectColumns();
|
||||
@@ -335,6 +358,8 @@ void CardListBase::onContextMenu(wxContextMenuEvent&) {
|
||||
|
||||
BEGIN_EVENT_TABLE(CardListBase, ItemList)
|
||||
EVT_LIST_COL_RIGHT_CLICK (wxID_ANY, CardListBase::onColumnRightClick)
|
||||
EVT_LIST_COL_DRAGGING (wxID_ANY, CardListBase::onColumnResize)
|
||||
EVT_LIST_COL_END_DRAG (wxID_ANY, CardListBase::onColumnResize)
|
||||
EVT_CHAR ( CardListBase::onChar)
|
||||
EVT_MOTION ( CardListBase::onDrag)
|
||||
EVT_MENU (ID_SELECT_COLUMNS, CardListBase::onSelectColumns)
|
||||
|
||||
@@ -112,17 +112,20 @@ class CardListBase : public ItemList, public SetView {
|
||||
/// Find the field that determines the color, if any.
|
||||
ChoiceFieldP findColorField();
|
||||
|
||||
/// Store the column sizes in the settings
|
||||
void storeColumns();
|
||||
public:
|
||||
public:
|
||||
/// Open a dialog for selecting columns to be shown
|
||||
void selectColumns();
|
||||
private:
|
||||
private:
|
||||
/// Store the column sizes in the settings
|
||||
void storeColumns();
|
||||
/// All card lists; used to exchange column sizes
|
||||
static vector<CardListBase*> card_lists;
|
||||
|
||||
// --------------------------------------------------- : Window events
|
||||
DECLARE_EVENT_TABLE();
|
||||
|
||||
void onColumnRightClick(wxListEvent& ev);
|
||||
void onColumnResize (wxListEvent& ev);
|
||||
void onSelectColumns (wxCommandEvent& ev);
|
||||
void onChar (wxKeyEvent& ev);
|
||||
void onDrag (wxMouseEvent& ev);
|
||||
|
||||
Reference in New Issue
Block a user