filtered card list is used

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@156 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2006-12-23 16:54:03 +00:00
parent dcdd000aef
commit f241fb91fa
4 changed files with 63 additions and 23 deletions
+13 -9
View File
@@ -18,6 +18,10 @@ DECLARE_TYPEOF_COLLECTION(int);
typedef map<String,UInt> map_String_UInt;
DECLARE_TYPEOF(map_String_UInt);
// ----------------------------------------------------------------------------- : Events
DEFINE_EVENT_TYPE(EVENT_GRAPH_SELECT);
// ----------------------------------------------------------------------------- : GraphData
GraphElement::GraphElement(const String& v1) {
@@ -254,21 +258,21 @@ void GraphControl::onMouseDown(wxMouseEvent& ev) {
if (!graph) return;
wxSize cs = GetClientSize();
if (graph->findItem(RealPoint(ev.GetX(), ev.GetY()), RealRect(RealPoint(0,0),cs), current_item)) {
wxCommandEvent ev(EVENT_GRAPH_SELECT, GetId());
ProcessEvent(ev);
Refresh(false);
}
}
bool GraphControl::hasSelection(size_t axis) const {
return current_item.size() >= axis && current_item[axis] >= 0;
return axis < current_item.size() && current_item[axis] >= 0;
}
void GraphControl::getSelection(vector<String>& out) const {
out.clear();
if (!graph) return;
FOR_EACH_2_CONST(i, current_item, a, graph->getData().axes) {
if (i >= 0) {
out.push_back((size_t)i < a->groups.size() ? a->groups[i].name : wxEmptyString);
}
}
String GraphControl::getSelection(size_t axis) const {
if (!graph || axis >= current_item.size() || axis >= graph->getData().axes.size()) return wxEmptyString;
GraphAxis& a = *graph->getData().axes[axis];
int i = current_item[axis];
if (i == -1 || (size_t)i >= a.groups.size()) return wxEmptyString;
return a.groups[current_item[axis]].name;
}
BEGIN_EVENT_TABLE(GraphControl, wxControl)