Files
MagicSetEditor2/src/gui/control/select_card_list.cpp
T
twanvl d2196eea09 Finally got precompiled headers to work.
Now all C++ files need to #include <util/prec.hpp>
 That is why all .cpp files are touched by this commit

Many changes to installers and update checking:
     - the window is now called PackagesWindow, in a new source file
     - update checking is now independent from the PackagesWindow. For update checking only a list of package versions are needed (vector<PackageDependency>). This is much less information to download at each startup.
     - the list of available packages is now a list of available Installers, since an installer can contain multiple packages.
     - moved the logic of dependency checking etc. to data/installer
     - moved the actual installation to util/io/package_manager
     - moved directory iteration/creation logic to util/file_utils
     - added PackageDirectory: the local and global package directory now have their own object (was part of PackageManager)
     - added PackageVersion: for detecting if a package has been modified after it was installed.
     - added PackageDescription: description/header of a package. Basicly the same as what Packaged provides.
     - added DownloadableInstaller: where to find an insaller, what does it contain?
     - added InstallablePackage: brining it all together: installer, package, status, action.

Current status: the insaller is currently broken in a few places, more on that soon.

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@792 0fc631ac-6414-0410-93d0-97cfa31319b6
2007-12-29 18:30:41 +00:00

109 lines
3.0 KiB
C++

//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2007 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <gui/control/select_card_list.hpp>
#include <gui/util.hpp>
#include <data/card.hpp>
#include <wx/imaglist.h>
DECLARE_TYPEOF_COLLECTION(CardP);
// ----------------------------------------------------------------------------- : SelectCardList
SelectCardList::SelectCardList(Window* parent, int id, long additional_style)
: CardListBase(parent, id, additional_style)
{
// create image list
wxImageList* il = new wxImageList(15,15);
il->Add(load_resource_image(_("sort_asc")), Color(255,0,255));
il->Add(load_resource_image(_("sort_desc")), Color(255,0,255));
il->Add(load_resource_image(_("deselected")));
il->Add(load_resource_image(_("selected")));
AssignImageList(il, wxIMAGE_LIST_SMALL);
}
SelectCardList::~SelectCardList() {}
void SelectCardList::selectAll() {
FOR_EACH_CONST(c, set->cards) {
selected.insert(c);
}
Refresh(false);
}
void SelectCardList::selectNone() {
selected.clear();
Refresh(false);
}
bool SelectCardList::isSelected(const CardP& card) const {
return selected.find(card) != selected.end();
}
void SelectCardList::onChangeSet() {
CardListBase::onChangeSet();
// init selected list: select all
selected.clear();
selectAll();
}
int SelectCardList::OnGetItemImage(long pos) const {
return isSelected(getCard(pos)) ? 3 : 2;
}
// ----------------------------------------------------------------------------- : Events
void SelectCardList::toggle(const CardP& card) {
if (isSelected(card)) {
selected.erase(card);
} else {
selected.insert(card);
}
}
void SelectCardList::onKeyDown(wxKeyEvent& ev) {
if (selected_item_pos == -1 || !selected_item) {
// no selection
ev.Skip();
return;
}
switch (ev.GetKeyCode()) {
case WXK_SPACE: {
toggle(getCard());
RefreshItem(selected_item_pos);
break;
}
case WXK_NUMPAD_ADD: case '+': {
selected.insert(getCard());
RefreshItem(selected_item_pos);
break;
}
case WXK_NUMPAD_SUBTRACT: case '-': {
selected.erase(getCard());
RefreshItem(selected_item_pos);
break;
}
default:
ev.Skip();
}
}
void SelectCardList::onLeftDown(wxMouseEvent& ev) {
int flags;
long item = HitTest(wxPoint(ev.GetX(), ev.GetY()), flags);
if (flags == wxLIST_HITTEST_ONITEMICON) {
// only clicking the icon toggles
toggle(getCard(item));
RefreshItem(item);
}
ev.Skip();
}
BEGIN_EVENT_TABLE(SelectCardList, CardListBase)
EVT_KEY_DOWN (SelectCardList::onKeyDown)
EVT_LEFT_DOWN (SelectCardList::onLeftDown)
END_EVENT_TABLE ()