mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
Added toolbar and menu for switching between graph layouts
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@914 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
+12
-2
@@ -15,12 +15,22 @@
|
||||
|
||||
/// Types of graphs
|
||||
enum GraphType
|
||||
{ GRAPH_TYPE_BAR
|
||||
, GRAPH_TYPE_PIE
|
||||
{ GRAPH_TYPE_PIE
|
||||
, GRAPH_TYPE_BAR
|
||||
, GRAPH_TYPE_STACK
|
||||
, GRAPH_TYPE_SCATTER
|
||||
, GRAPH_TYPE_SCATTER_PIE
|
||||
};
|
||||
|
||||
/// Dimensions for each graph type
|
||||
inline size_t dimensionality(GraphType type) {
|
||||
if (type == GRAPH_TYPE_PIE) return 1;
|
||||
if (type == GRAPH_TYPE_BAR) return 1;
|
||||
if (type == GRAPH_TYPE_STACK) return 2;
|
||||
if (type == GRAPH_TYPE_SCATTER) return 2;
|
||||
if (type == GRAPH_TYPE_SCATTER_PIE) return 3;
|
||||
else return 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
#endif
|
||||
|
||||
@@ -802,8 +802,8 @@ GraphControl::GraphControl(Window* parent, int id)
|
||||
: wxControl(parent, id, wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS)
|
||||
{}
|
||||
|
||||
void GraphControl::setLayout(GraphType type) {
|
||||
if (graph && type == layout) return;
|
||||
void GraphControl::setLayout(GraphType type, bool force) {
|
||||
if (!force && graph && type == layout) return;
|
||||
GraphDataP data = graph ? graph->getData() : GraphDataP();
|
||||
switch (type) {
|
||||
case GRAPH_TYPE_BAR: {
|
||||
@@ -815,7 +815,8 @@ void GraphControl::setLayout(GraphType type) {
|
||||
break;
|
||||
} case GRAPH_TYPE_PIE: {
|
||||
intrusive_ptr<GraphContainer> combined(new GraphContainer());
|
||||
combined->add(new_intrusive1<PieGraph>(0));
|
||||
combined->add(new_intrusive5<GraphWithMargins>(new_intrusive1<PieGraph>(0), 0,0,120,0));
|
||||
combined->add(new_intrusive3<GraphLegend>(0, ALIGN_TOP_RIGHT, true));
|
||||
graph = new_intrusive5<GraphWithMargins>(combined, 20,20,20,20);
|
||||
break;
|
||||
} case GRAPH_TYPE_STACK: {
|
||||
@@ -847,6 +848,10 @@ void GraphControl::setLayout(GraphType type) {
|
||||
layout = type;
|
||||
}
|
||||
|
||||
GraphType GraphControl::getLayout() const {
|
||||
return layout;
|
||||
}
|
||||
|
||||
void GraphControl::setData(const GraphDataPre& data) {
|
||||
setData(new_intrusive1<GraphData>(data));
|
||||
}
|
||||
@@ -858,6 +863,11 @@ void GraphControl::setData(const GraphDataP& data) {
|
||||
Refresh(false);
|
||||
}
|
||||
|
||||
size_t GraphControl::getDimensionality() const {
|
||||
if (graph) return graph->getData()->axes.size();
|
||||
else return 0;
|
||||
}
|
||||
|
||||
void GraphControl::onPaint(wxPaintEvent&) {
|
||||
wxBufferedPaintDC dc(this);
|
||||
wxSize cs = GetClientSize();
|
||||
|
||||
@@ -305,7 +305,7 @@ class GraphControl : public wxControl {
|
||||
GraphControl(Window* parent, int id);
|
||||
|
||||
/// Set the type of graph used, from a number of predefined choices
|
||||
void setLayout(GraphType type);
|
||||
void setLayout(GraphType type, bool force_refresh = false);
|
||||
/// Update the data in the graph
|
||||
void setData(const GraphDataPre& data);
|
||||
/// Update the data in the graph
|
||||
@@ -316,6 +316,11 @@ class GraphControl : public wxControl {
|
||||
/// Get the current item along the given axis
|
||||
String getSelection(size_t axis) const;
|
||||
|
||||
/// Get the current layout
|
||||
GraphType getLayout() const;
|
||||
/// Get the current dimensionality
|
||||
size_t getDimensionality() const;
|
||||
|
||||
private:
|
||||
/// Graph object
|
||||
GraphP graph;
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#include <gui/control/graph.hpp>
|
||||
#include <gui/control/gallery_list.hpp>
|
||||
#include <gui/control/filtered_card_list.hpp>
|
||||
#include <gui/icon_menu.hpp>
|
||||
#include <gui/util.hpp>
|
||||
#include <data/game.hpp>
|
||||
#include <data/statistics.hpp>
|
||||
#include <util/window_id.hpp>
|
||||
@@ -26,7 +28,7 @@ typedef pair<StatsDimensionP,String> pair_StatsDimensionP_String;
|
||||
DECLARE_TYPEOF_COLLECTION(pair_StatsDimensionP_String);
|
||||
|
||||
// Pick the style here:
|
||||
#define USE_DIMENSION_LISTS 0
|
||||
#define USE_DIMENSION_LISTS 1
|
||||
|
||||
// ----------------------------------------------------------------------------- : StatCategoryList
|
||||
|
||||
@@ -218,6 +220,18 @@ StatsPanel::StatsPanel(Window* parent, int id)
|
||||
s->Add(splitter, 1, wxEXPAND);
|
||||
s->SetSizeHints(this);
|
||||
SetSizer(s);
|
||||
|
||||
// init menu
|
||||
menuGraph = new IconMenu();
|
||||
menuGraph->Append(ID_GRAPH_PIE, _("graph_pie"), _MENU_("pie"), _HELP_("pie"), wxITEM_CHECK);
|
||||
menuGraph->Append(ID_GRAPH_BAR, _("graph_bar"), _MENU_("bar"), _HELP_("bar"), wxITEM_CHECK);
|
||||
menuGraph->Append(ID_GRAPH_STACK, _("graph_stack"), _MENU_("stack"), _HELP_("stack"), wxITEM_CHECK);
|
||||
menuGraph->Append(ID_GRAPH_SCATTER, _("graph_scatter"), _MENU_("scatter"), _HELP_("scatter"), wxITEM_CHECK);
|
||||
menuGraph->Append(ID_GRAPH_SCATTER_PIE, _("graph_scatter_pie"), _MENU_("scatter pie"), _HELP_("scatter pie"), wxITEM_CHECK);
|
||||
}
|
||||
|
||||
StatsPanel::~StatsPanel() {
|
||||
delete menuGraph;
|
||||
}
|
||||
|
||||
void StatsPanel::onChangeSet() {
|
||||
@@ -234,12 +248,44 @@ void StatsPanel::onAction(const Action&, bool undone) {
|
||||
onChange();
|
||||
}
|
||||
|
||||
void StatsPanel::initUI (wxToolBar*, wxMenuBar*) {
|
||||
void StatsPanel::initUI (wxToolBar* tb, wxMenuBar* mb) {
|
||||
active = true;
|
||||
if (!up_to_date) showCategory();
|
||||
// Toolbar
|
||||
#if USE_DIMENSION_LISTS
|
||||
tb->AddTool(ID_GRAPH_PIE, _(""), load_resource_tool_image(_("graph_pie")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("pie"), _HELP_("pie"));
|
||||
tb->AddTool(ID_GRAPH_BAR, _(""), load_resource_tool_image(_("graph_bar")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("bar"), _HELP_("bar"));
|
||||
tb->AddTool(ID_GRAPH_STACK, _(""), load_resource_tool_image(_("graph_stack")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("stack"), _HELP_("stack"));
|
||||
tb->AddTool(ID_GRAPH_SCATTER, _(""), load_resource_tool_image(_("graph_scatter")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("scatter"), _HELP_("scatter"));
|
||||
tb->AddTool(ID_GRAPH_SCATTER_PIE, _(""), load_resource_tool_image(_("graph_scatter_pie")), wxNullBitmap, wxITEM_CHECK, _TOOLTIP_("scatter pie"), _HELP_("scatter pie"));
|
||||
tb->Realize();
|
||||
// Menu
|
||||
mb->Insert(2, menuGraph, _MENU_("graph"));
|
||||
#endif
|
||||
}
|
||||
void StatsPanel::destroyUI(wxToolBar*, wxMenuBar*) {
|
||||
void StatsPanel::destroyUI(wxToolBar* tb, wxMenuBar* mb) {
|
||||
active = false;
|
||||
#if USE_DIMENSION_LISTS
|
||||
// Toolbar
|
||||
tb->DeleteTool(ID_GRAPH_PIE);
|
||||
tb->DeleteTool(ID_GRAPH_BAR);
|
||||
tb->DeleteTool(ID_GRAPH_STACK);
|
||||
tb->DeleteTool(ID_GRAPH_SCATTER);
|
||||
tb->DeleteTool(ID_GRAPH_SCATTER_PIE);
|
||||
// Menus
|
||||
mb->Remove(2);
|
||||
#endif
|
||||
}
|
||||
|
||||
void StatsPanel::onUpdateUI(wxUpdateUIEvent& ev) {
|
||||
switch (ev.GetId()) {
|
||||
case ID_GRAPH_PIE: case ID_GRAPH_BAR: case ID_GRAPH_STACK: case ID_GRAPH_SCATTER: case ID_GRAPH_SCATTER_PIE: {
|
||||
GraphType type = (GraphType)(ev.GetId() - ID_GRAPH_PIE);
|
||||
ev.Check(graph->getLayout() == type);
|
||||
ev.Enable(graph->getDimensionality() == dimensionality(type));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StatsPanel::onCommand(int id) {
|
||||
@@ -248,6 +294,12 @@ void StatsPanel::onCommand(int id) {
|
||||
onChange();
|
||||
break;
|
||||
}
|
||||
case ID_GRAPH_PIE: case ID_GRAPH_BAR: case ID_GRAPH_STACK: case ID_GRAPH_SCATTER: case ID_GRAPH_SCATTER_PIE: {
|
||||
GraphType type = (GraphType)(id - ID_GRAPH_PIE);
|
||||
graph->setLayout(type);
|
||||
graph->Refresh(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,9 +382,14 @@ void StatsPanel::showCategory() {
|
||||
if (dim->split_list) d.splitList(dim_id);
|
||||
++dim_id;
|
||||
}
|
||||
graph->setLayout(dims.size() == 1 ? GRAPH_TYPE_BAR
|
||||
:dims.size() == 2 ? GRAPH_TYPE_STACK
|
||||
: GRAPH_TYPE_SCATTER_PIE);
|
||||
GraphType layout = graph->getLayout();
|
||||
if (dimensionality(layout) != dims.size()) {
|
||||
// we must switch to another layout
|
||||
layout = dims.size() == 1 ? GRAPH_TYPE_BAR
|
||||
: dims.size() == 2 ? GRAPH_TYPE_STACK
|
||||
: GRAPH_TYPE_SCATTER_PIE;
|
||||
}
|
||||
graph->setLayout(layout, true);
|
||||
graph->setData(d);
|
||||
filterCards();
|
||||
#else
|
||||
@@ -376,7 +433,7 @@ void StatsPanel::showCategory() {
|
||||
++dim_id;
|
||||
}
|
||||
graph->setLayout(cat.type);
|
||||
graph->setData(d);
|
||||
graph->setData(d, true);
|
||||
filterCards();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -16,6 +16,7 @@ class StatCategoryList;
|
||||
class StatDimensionList;
|
||||
class GraphControl;
|
||||
class FilteredCardList;
|
||||
class IconMenu;
|
||||
|
||||
// ----------------------------------------------------------------------------- : StatsPanel
|
||||
|
||||
@@ -23,6 +24,7 @@ class FilteredCardList;
|
||||
class StatsPanel : public SetWindowPanel {
|
||||
public:
|
||||
StatsPanel(Window* parent, int id);
|
||||
~StatsPanel();
|
||||
|
||||
// --------------------------------------------------- : UI
|
||||
|
||||
@@ -31,6 +33,7 @@ class StatsPanel : public SetWindowPanel {
|
||||
|
||||
virtual void initUI (wxToolBar*, wxMenuBar*);
|
||||
virtual void destroyUI(wxToolBar*, wxMenuBar*);
|
||||
virtual void onUpdateUI(wxUpdateUIEvent&);
|
||||
virtual void onCommand(int id);
|
||||
|
||||
// --------------------------------------------------- : Selection
|
||||
@@ -45,6 +48,7 @@ class StatsPanel : public SetWindowPanel {
|
||||
StatDimensionList* dimensions[3];
|
||||
GraphControl* graph;
|
||||
FilteredCardList* card_list;
|
||||
IconMenu* menuGraph;
|
||||
|
||||
bool up_to_date; ///< Are the graph and card list up to date?
|
||||
bool active; ///< Is this panel selected?
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# This file contains the keys expected to be in MSE locales
|
||||
# It was automatically generated by tools/locale/locale.pl
|
||||
# Generated on Sat May 31 19:21:25 2008
|
||||
# Generated on Sat May 31 21:42:09 2008
|
||||
|
||||
action:
|
||||
add control point: 0
|
||||
@@ -135,6 +135,7 @@ help:
|
||||
add symmetry: 0
|
||||
app language: 0
|
||||
auto replace: 0
|
||||
bar: 0
|
||||
basic shapes: 0
|
||||
bold: 0
|
||||
border: 0
|
||||
@@ -199,6 +200,7 @@ help:
|
||||
paste: 0
|
||||
paste card: 0
|
||||
paste keyword: 0
|
||||
pie: 0
|
||||
points: 0
|
||||
polygon: 0
|
||||
preferences: 0
|
||||
@@ -226,12 +228,15 @@ help:
|
||||
save set as: 0
|
||||
save symbol: 0
|
||||
save symbol as: 0
|
||||
scatter: 0
|
||||
scatter pie: 0
|
||||
select: 0
|
||||
set code: 0
|
||||
set info tab: 0
|
||||
sides: 0
|
||||
smooth point: 0
|
||||
snap: 0
|
||||
stack: 0
|
||||
star: 0
|
||||
stats tab: 0
|
||||
store symbol: 0
|
||||
@@ -306,6 +311,7 @@ menu:
|
||||
add cards: 0
|
||||
add keyword: 0
|
||||
auto replace: 0
|
||||
bar: 0
|
||||
basic shapes: 0
|
||||
bold: 0
|
||||
card list columns: 0
|
||||
@@ -329,6 +335,7 @@ menu:
|
||||
find: 0
|
||||
find next: 0
|
||||
format: 0
|
||||
graph: 0
|
||||
group: 0
|
||||
help: 0
|
||||
index: 0
|
||||
@@ -346,6 +353,7 @@ menu:
|
||||
orientation: 0
|
||||
paint: 0
|
||||
paste: 0
|
||||
pie: 0
|
||||
points: 0
|
||||
preferences: 0
|
||||
previous card: 0
|
||||
@@ -367,8 +375,11 @@ menu:
|
||||
save set as: 0
|
||||
save symbol: 0
|
||||
save symbol as: 0
|
||||
scatter: 0
|
||||
scatter pie: 0
|
||||
select: 0
|
||||
set info tab: 0
|
||||
stack: 0
|
||||
stats tab: 0
|
||||
store symbol: 0
|
||||
style tab: 0
|
||||
@@ -453,6 +464,7 @@ tooltip:
|
||||
add card: 0
|
||||
add keyword: 0
|
||||
add symmetry: 0
|
||||
bar: 0
|
||||
basic shapes: 0
|
||||
bold: 0
|
||||
border: 0
|
||||
@@ -476,6 +488,7 @@ tooltip:
|
||||
overlap: 0
|
||||
paint: optional, 0
|
||||
paste: 0
|
||||
pie: 0
|
||||
points: 0
|
||||
polygon: 0
|
||||
rectangle: 0
|
||||
@@ -489,10 +502,13 @@ tooltip:
|
||||
rotate card: 0
|
||||
rotation: 0
|
||||
save set: 0
|
||||
scatter: 0
|
||||
scatter pie: 0
|
||||
select: 0
|
||||
set info tab: 0
|
||||
smooth point: 0
|
||||
snap: 0
|
||||
stack: 0
|
||||
star: 0
|
||||
stats tab: 0
|
||||
store symbol: 0
|
||||
|
||||
@@ -54,6 +54,12 @@ tool/card_rotate_270 IMAGE "tool/card_rotate_270.png"
|
||||
tool/keyword_add IMAGE "tool/keyword_add.png"
|
||||
tool/keyword_del IMAGE "tool/keyword_del.png"
|
||||
|
||||
tool/graph_pie IMAGE "tool/graph_pie.png"
|
||||
tool/graph_bar IMAGE "tool/graph_bar.png"
|
||||
tool/graph_stack IMAGE "tool/graph_stack.png"
|
||||
tool/graph_scatter IMAGE "tool/graph_scatter.png"
|
||||
tool/graph_scatter_pie IMAGE "tool/graph_scatter_pie.png"
|
||||
|
||||
tool/window_cards IMAGE "tool/window_cards.png"
|
||||
tool/window_set_info IMAGE "tool/window_set_info.png"
|
||||
tool/window_style IMAGE "tool/window_style.png"
|
||||
|
||||
@@ -119,6 +119,13 @@ enum ChildMenuID {
|
||||
, ID_FORMAT_REMINDER
|
||||
, ID_INSERT_SYMBOL
|
||||
|
||||
// Graph menu
|
||||
, ID_GRAPH_PIE = 1301 // corresponds to GraphType
|
||||
, ID_GRAPH_BAR
|
||||
, ID_GRAPH_STACK
|
||||
, ID_GRAPH_SCATTER
|
||||
, ID_GRAPH_SCATTER_PIE
|
||||
|
||||
// SymbolSelectEditor toolbar/menu
|
||||
, ID_SYMBOL_COMBINE = 2001
|
||||
, ID_SYMBOL_COMBINE_MERGE = ID_SYMBOL_COMBINE + 0 //SYMBOL_COMBINE_MERGE
|
||||
|
||||
Reference in New Issue
Block a user