Commit 2c81e5d4 authored by twanvl's avatar twanvl

all card lists share the widths of the columns

parent ec4829f2
...@@ -28,6 +28,7 @@ DECLARE_TYPEOF_COLLECTION(FieldP); ...@@ -28,6 +28,7 @@ DECLARE_TYPEOF_COLLECTION(FieldP);
DECLARE_POINTER_TYPE(ChoiceValue); DECLARE_POINTER_TYPE(ChoiceValue);
DECLARE_TYPEOF(map<int COMMA FieldP>); DECLARE_TYPEOF(map<int COMMA FieldP>);
DECLARE_TYPEOF_NO_REV(IndexMap<FieldP COMMA StyleP>); DECLARE_TYPEOF_NO_REV(IndexMap<FieldP COMMA StyleP>);
DECLARE_TYPEOF_COLLECTION(CardListBase*);
// ----------------------------------------------------------------------------- : Events // ----------------------------------------------------------------------------- : Events
...@@ -35,12 +36,19 @@ DEFINE_EVENT_TYPE(EVENT_CARD_SELECT); ...@@ -35,12 +36,19 @@ DEFINE_EVENT_TYPE(EVENT_CARD_SELECT);
// ----------------------------------------------------------------------------- : CardListBase // ----------------------------------------------------------------------------- : CardListBase
vector<CardListBase*> CardListBase::card_lists;
CardListBase::CardListBase(Window* parent, int id, long additional_style) CardListBase::CardListBase(Window* parent, int id, long additional_style)
: ItemList(parent, id, additional_style) : ItemList(parent, id, additional_style)
{} {
// add to the list of card lists
card_lists.push_back(this);
}
CardListBase::~CardListBase() { CardListBase::~CardListBase() {
storeColumns(); storeColumns();
// remove from list of card lists
card_lists.erase(remove(card_lists.begin(), card_lists.end(), this));
} }
void CardListBase::onBeforeChangeSet() { void CardListBase::onBeforeChangeSet() {
...@@ -245,7 +253,12 @@ void CardListBase::storeColumns() { ...@@ -245,7 +253,12 @@ void CardListBase::storeColumns() {
void CardListBase::selectColumns() { void CardListBase::selectColumns() {
CardListColumnSelectDialog wnd(this, set->game); CardListColumnSelectDialog wnd(this, set->game);
if (wnd.ShowModal() == wxID_OK) { 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&) { ...@@ -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.")); m->Append(ID_SELECT_COLUMNS, _("&Select Columns..."), _("Select what columns should be shown and in what order."));
PopupMenu(m); 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&) { void CardListBase::onSelectColumns(wxCommandEvent&) {
selectColumns(); selectColumns();
...@@ -335,6 +358,8 @@ void CardListBase::onContextMenu(wxContextMenuEvent&) { ...@@ -335,6 +358,8 @@ void CardListBase::onContextMenu(wxContextMenuEvent&) {
BEGIN_EVENT_TABLE(CardListBase, ItemList) BEGIN_EVENT_TABLE(CardListBase, ItemList)
EVT_LIST_COL_RIGHT_CLICK (wxID_ANY, CardListBase::onColumnRightClick) 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_CHAR ( CardListBase::onChar)
EVT_MOTION ( CardListBase::onDrag) EVT_MOTION ( CardListBase::onDrag)
EVT_MENU (ID_SELECT_COLUMNS, CardListBase::onSelectColumns) EVT_MENU (ID_SELECT_COLUMNS, CardListBase::onSelectColumns)
......
...@@ -112,17 +112,20 @@ class CardListBase : public ItemList, public SetView { ...@@ -112,17 +112,20 @@ class CardListBase : public ItemList, public SetView {
/// Find the field that determines the color, if any. /// Find the field that determines the color, if any.
ChoiceFieldP findColorField(); ChoiceFieldP findColorField();
/// Store the column sizes in the settings
void storeColumns();
public: public:
/// Open a dialog for selecting columns to be shown /// Open a dialog for selecting columns to be shown
void selectColumns(); 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 // --------------------------------------------------- : Window events
DECLARE_EVENT_TABLE(); DECLARE_EVENT_TABLE();
void onColumnRightClick(wxListEvent& ev); void onColumnRightClick(wxListEvent& ev);
void onColumnResize (wxListEvent& ev);
void onSelectColumns (wxCommandEvent& ev); void onSelectColumns (wxCommandEvent& ev);
void onChar (wxKeyEvent& ev); void onChar (wxKeyEvent& ev);
void onDrag (wxMouseEvent& ev); void onDrag (wxMouseEvent& ev);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment