mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
added SetWindow (formerly MainWindow)
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@8 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -64,7 +64,7 @@ void IconMenu::Append(int id, const String& text, const String& help) {
|
||||
wxMenu::Append(item);
|
||||
}
|
||||
|
||||
void IconMenu::Append(int id, const String& text, wxMenu* submenu, const String& help) {
|
||||
void IconMenu::Append(int id, const String& text, const String& help, wxMenu* submenu) {
|
||||
wxMenuItem* item = new wxMenuItem (this, id, text, help, wxITEM_NORMAL, submenu);
|
||||
item->SetBitmap(wxNullBitmap);
|
||||
wxMenu::Append(item);
|
||||
|
||||
@@ -26,7 +26,7 @@ class IconMenu : public wxMenu {
|
||||
/// Append a menu item, without an image
|
||||
void Append(int id, const String& text, const String& help);
|
||||
/// Append a menu item, without an image
|
||||
void Append(int id, const String& text, wxMenu* submenu, const String& help);
|
||||
void Append(int id, const String& text, const String& help, wxMenu* submenu);
|
||||
/// Insert a menu item, without an image
|
||||
void Insert(size_t pos, int id, const String& text, const String& help);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
|
||||
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
|
||||
//| License: GNU General Public License 2 or later (see file COPYING) |
|
||||
//+----------------------------------------------------------------------------+
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <gui/set/cards_panel.hpp>
|
||||
|
||||
// ----------------------------------------------------------------------------- :
|
||||
@@ -0,0 +1,106 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
|
||||
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
|
||||
//| License: GNU General Public License 2 or later (see file COPYING) |
|
||||
//+----------------------------------------------------------------------------+
|
||||
|
||||
#ifndef HEADER_GUI_SET_CARDS_PANEL
|
||||
#define HEADER_GUI_SET_CARDS_PANEL
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <gui/set/panel.hpp>
|
||||
|
||||
// ----------------------------------------------------------------------------- : CardsPanel
|
||||
|
||||
/// A card list and card editor panel
|
||||
class CardsPanel : public SetWindowPanel {
|
||||
public:
|
||||
CardsPanel(Window* parent, int id);
|
||||
~CardsPanel();
|
||||
|
||||
void onSetChange();
|
||||
|
||||
// --------------------------------------------------- : Meta information
|
||||
virtual String shortName();
|
||||
virtual String longName();
|
||||
virtual String description();
|
||||
|
||||
// --------------------------------------------------- : UI
|
||||
|
||||
virtual void initUI (wxToolBar* tb, wxMenuBar* mb);
|
||||
virtual void destroyUI(wxToolBar* tb, wxMenuBar* mb);
|
||||
virtual void onUpdateUI(wxUpdateUIEvent& e);
|
||||
virtual void onCommand(int id);
|
||||
|
||||
// --------------------------------------------------- : Actions
|
||||
|
||||
virtual bool wantsToHandle(const Action&);
|
||||
virtual void onAction(const Action&);
|
||||
virtual void onRenderSettingsChange();
|
||||
private:
|
||||
void updateSize();
|
||||
public:
|
||||
|
||||
// --------------------------------------------------- : Clipboard
|
||||
virtual bool canCut();
|
||||
virtual bool canCopy();
|
||||
virtual bool canPaste();
|
||||
virtual void doCut();
|
||||
virtual void doCopy();
|
||||
virtual void doPaste();
|
||||
|
||||
// --------------------------------------------------- : Searching (find/replace)
|
||||
virtual bool canFind();
|
||||
virtual bool canReplace();
|
||||
virtual bool doFind(wxFindReplaceData& what);
|
||||
virtual bool doReplace(wxFindReplaceData& what);
|
||||
private:
|
||||
// Functions that handle finding
|
||||
/*
|
||||
typedef void (CardsPanel::*FindHandler)(const CardP&, const TextValueP&, const size_t, const size_t, wxFindReplaceData&);
|
||||
|
||||
/// Execute a find (or replace), and start with the currently selected card and value
|
||||
/** if findSame==true then find will also find the currently highlighted word
|
||||
* Returns true if found
|
||||
* /
|
||||
bool find(FindReplaceData& what, const FindHandler& handler, bool findSame = false);
|
||||
|
||||
/// find handler : select found value
|
||||
void handleFind(const CardP& card, const TextValueP& value, size_t start, size_t end, FindReplaceData& what);
|
||||
|
||||
/// replace handler : replace found value, move selection to end
|
||||
void handleReplace(const CardP& card, const TextValueP& value, size_t start, size_t end, FindReplaceData& what);
|
||||
|
||||
/// Find in all cards
|
||||
/** NOTE: this function is essentially the same as findInCard * /
|
||||
bool findInCards(const CardP& firstCard, const ValueP& firstValue, int firstChar, FindReplaceData& what, const FindHandler& handler);
|
||||
|
||||
/// Find in a card, if firstValue is specified start searching there
|
||||
/** NOTE: this function is essentially the same as findInCards * /
|
||||
bool findInCard(const CardP& card, const ValueP& firstValue, int firstChar, FindReplaceData& what, const FindHandler& handler);
|
||||
|
||||
/// Find the current search string in the specified value
|
||||
/** if searchDir = up searches from the end and only before firstChar, unless firstChar == -1 * /
|
||||
bool findInValue(const CardP& crd_, virtual const ValueP& value, int firstChar, FindReplaceData& what, const FindHandler& handler);
|
||||
*/
|
||||
public:
|
||||
|
||||
// --------------------------------------------------- : Selection
|
||||
virtual CardP selectedCard();
|
||||
virtual void selectCard(const CardP& card);
|
||||
|
||||
private:
|
||||
// --------------------------------------------------- : Controls
|
||||
// wxSplitterWindow* splitter;
|
||||
// Editor* editor;
|
||||
// EditCardList* cardList;
|
||||
// DataTextCtrl* notes;
|
||||
|
||||
// --------------------------------------------------- : Menus & tools
|
||||
wxMenu* cardMenu, formatMenu;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
#endif
|
||||
@@ -0,0 +1,92 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
|
||||
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
|
||||
//| License: GNU General Public License 2 or later (see file COPYING) |
|
||||
//+----------------------------------------------------------------------------+
|
||||
|
||||
#ifndef HEADER_GUI_SET_PANEL
|
||||
#define HEADER_GUI_SET_PANEL
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <data/set.hpp>
|
||||
|
||||
class wxFindReplaceData;
|
||||
|
||||
// ----------------------------------------------------------------------------- : SetWindowPanel
|
||||
|
||||
/// A panel that is one of the panels in the set window.
|
||||
/** This class is a virtual base class for all actual panels used in the set window.
|
||||
*/
|
||||
class SetWindowPanel : public wxPanel, public SetView {
|
||||
public:
|
||||
SetWindowPanel(Window* parent, int id, bool autoTabbing = false);
|
||||
|
||||
/// We will probably want to respond to set changes
|
||||
virtual void onSetChange();
|
||||
|
||||
// --------------------------------------------------- : Meta information
|
||||
|
||||
virtual String shortName() { return _("<undefined>"); } ///< for tab bar
|
||||
virtual String longName() { return shortName(); } ///< for menu
|
||||
virtual String description() { return _("<undefined>"); } ///< for status bar
|
||||
virtual String helpFile() { return _(""); } ///< help file to use when this panel is active
|
||||
|
||||
// --------------------------------------------------- : UI
|
||||
|
||||
/// Init extra toolbar items and menus needed for this panel.
|
||||
virtual void initUI (wxToolBar* tb, wxMenuBar* mb) {}
|
||||
/// Destroy the extra items added by initUI.
|
||||
virtual void destroyUI(wxToolBar* tb, wxMenuBar* mb) {}
|
||||
/// Update the UI by enabling/disabling items.
|
||||
/** Note: copy/paste and find/replace are not handled here.
|
||||
*/
|
||||
virtual void onUpdateUI(wxUpdateUIEvent& e) {}
|
||||
/// Respond to one of those extra menu/tool items
|
||||
virtual void onCommand(int id) {}
|
||||
|
||||
// --------------------------------------------------- : Actions/Events
|
||||
|
||||
/// Should return true if this panel wants to get focus to show an action
|
||||
virtual bool wantsToHandle(const Action&) { return false; }
|
||||
/// The settings for rendering cards have changed, refresh card viewers/editors
|
||||
virtual void onRenderSettingsChange() {}
|
||||
|
||||
// --------------------------------------------------- : Clipboard
|
||||
virtual bool canPaste() { return false; } ///< Is pasting possible?
|
||||
virtual bool canCopy() { return false; } ///< Is copying possible?
|
||||
virtual bool canCut() { return canCopy(); } ///< Is cutting possible?
|
||||
virtual void doPaste() {} ///< Paste the contents of the clipboard
|
||||
virtual void doCopy() {} ///< Copy the selection to the clipboard
|
||||
virtual void doCut() {} ///< Cut the selection to the clipboard
|
||||
|
||||
// --------------------------------------------------- : Searching (find/replace)
|
||||
virtual bool canFind() { return false; } ///< Is finding possible?
|
||||
virtual bool canReplace() { return false; } ///< Is replacing possible?
|
||||
virtual bool doFind(wxFindReplaceData&) { return false; } ///< Find the next math
|
||||
virtual bool doReplace(wxFindReplaceData&) { return false; } ///< Replace the next match
|
||||
|
||||
// --------------------------------------------------- : Selection
|
||||
virtual CardP selectedCard() { return CardP(); } ///< Return the currently selected card, or CardP()
|
||||
virtual void selectCard(CardP card) {} ///< Switch the view to another card
|
||||
|
||||
protected:
|
||||
// --------------------------------------------------- : Helper functions for UI
|
||||
/// Enable/disable a tool or menu item
|
||||
// void enable(wxToolBar* tb, wxMenuBar* mb, int id, bool enable);
|
||||
// mb->Enable(id, enable)
|
||||
// tb->EnableTool(id, enable)
|
||||
|
||||
/// Id of the control that has the focus, or -1 if no control has the focus
|
||||
int focusedControl();
|
||||
// Window* focusedWindow = findFocus()
|
||||
// // is this window actually inside this panel?
|
||||
// if focusedWindow && findWindowById(focusedWindow->id, &this) == focusedWindow
|
||||
// return focusedWindow->id
|
||||
// else
|
||||
// return -1 // no window has the focus, or it has a different parent/ancestor
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
|
||||
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
|
||||
//| License: GNU General Public License 2 or later (see file COPYING) |
|
||||
//+----------------------------------------------------------------------------+
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <gui/set/set_info_panel.hpp>
|
||||
|
||||
// ----------------------------------------------------------------------------- :
|
||||
@@ -0,0 +1,18 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
|
||||
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
|
||||
//| License: GNU General Public License 2 or later (see file COPYING) |
|
||||
//+----------------------------------------------------------------------------+
|
||||
|
||||
#ifndef HEADER_GUI_SET_SET_INFO_PANEL
|
||||
#define HEADER_GUI_SET_SET_INFO_PANEL
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
|
||||
// ----------------------------------------------------------------------------- :
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
|
||||
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
|
||||
//| License: GNU General Public License 2 or later (see file COPYING) |
|
||||
//+----------------------------------------------------------------------------+
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <gui/set/stats_panel.hpp>
|
||||
|
||||
// ----------------------------------------------------------------------------- : StatsPanel
|
||||
@@ -0,0 +1,19 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
|
||||
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
|
||||
//| License: GNU General Public License 2 or later (see file COPYING) |
|
||||
//+----------------------------------------------------------------------------+
|
||||
|
||||
#ifndef HEADER_GUI_SET_STATS_PANEL
|
||||
#define HEADER_GUI_SET_STATS_PANEL
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <gui/set/panel.hpp>
|
||||
|
||||
// ----------------------------------------------------------------------------- : StatsPanel
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
|
||||
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
|
||||
//| License: GNU General Public License 2 or later (see file COPYING) |
|
||||
//+----------------------------------------------------------------------------+
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <gui/set/style_panel.hpp>
|
||||
|
||||
// ----------------------------------------------------------------------------- :
|
||||
@@ -0,0 +1,18 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
|
||||
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
|
||||
//| License: GNU General Public License 2 or later (see file COPYING) |
|
||||
//+----------------------------------------------------------------------------+
|
||||
|
||||
#ifndef HEADER_GUI_SET_STYLE_PANEL
|
||||
#define HEADER_GUI_SET_STYLE_PANEL
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
|
||||
// ----------------------------------------------------------------------------- :
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
#endif
|
||||
@@ -0,0 +1,584 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
|
||||
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
|
||||
//| License: GNU General Public License 2 or later (see file COPYING) |
|
||||
//+----------------------------------------------------------------------------+
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <gui/set/window.hpp>
|
||||
#include <gui/set/panel.hpp>
|
||||
#include <gui/set/cards_panel.hpp>
|
||||
#include <gui/set/set_info_panel.hpp>
|
||||
#include <gui/set/style_panel.hpp>
|
||||
#include <gui/set/stats_panel.hpp>
|
||||
#include <gui/icon_menu.hpp>
|
||||
#include <util/window_id.hpp>
|
||||
#include <data/game.hpp>
|
||||
#include <data/set.hpp>
|
||||
#include <data/card.hpp>
|
||||
#include <data/settings.hpp>
|
||||
#include <data/format/formats.hpp>
|
||||
|
||||
DECLARE_TYPEOF_COLLECTION(SetWindowPanel*);
|
||||
|
||||
// ----------------------------------------------------------------------------- : Constructor
|
||||
|
||||
SetWindow::SetWindow(Window* parent)
|
||||
: wxFrame(parent, wxID_ANY, _("Magic Set Editor"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE)
|
||||
, currentPanel(nullptr)
|
||||
, findDialog(nullptr)
|
||||
{
|
||||
SetIcon(wxIcon(_("ICON_APP")));
|
||||
|
||||
// initialize menu bar
|
||||
wxMenuBar* menuBar = new wxMenuBar();
|
||||
IconMenu* menuFile = new IconMenu();
|
||||
menuFile->Append(ID_FILE_NEW, _("TOOL_NEW"), _("&New...\tCtrl+N"), _("Create a new set"));
|
||||
menuFile->Append(ID_FILE_OPEN, _("TOOL_OPEN"), _("&Open...\tCtrl+O"), _("Open a set"));
|
||||
menuFile->Append(ID_FILE_SAVE, _("TOOL_SAVE"), _("&Save\tCtrl+S"), _("Save the set"));
|
||||
menuFile->Append(ID_FILE_SAVE_AS, _("Save &As...\tF12"), _("Save the set with a new name"));
|
||||
IconMenu* menuExport = new IconMenu();
|
||||
menuExport->Append(ID_FILE_EXPORT_HTML, _("&HTML..."), _("Export the set to a HTML file"));
|
||||
menuExport->Append(ID_FILE_EXPORT_IMAGE, _("Card &Image::.."), _("Export the selected card to an image file"));
|
||||
menuExport->Append(ID_FILE_EXPORT_IMAGES, _("All Card I&mages..."), _("Export images for all cards"));
|
||||
menuExport->Append(ID_FILE_EXPORT_APPR, _("&Apprentice::.."), _("Export the set so it can be played with in Apprentice"));
|
||||
menuExport->Append(ID_FILE_EXPORT_MWS, _("Magic &Workstation::.."), _("Export the set so it can be played with in Magic Workstation"));
|
||||
menuFile->Append(ID_FILE_EXPORT, _("&Export"), _("Export the set..."), menuExport);
|
||||
menuFile->AppendSeparator();
|
||||
menuFile->Append(ID_FILE_INSPECT, _("Inspect Internal Data..."), _("Shows a the data in the set using a tree structure"));
|
||||
menuFile->AppendSeparator();
|
||||
menuFile->Append(ID_FILE_PRINT_PREVIEW, _("Print Pre&view..."), _("Shows cards as they will be printed"));
|
||||
menuFile->Append(ID_FILE_PRINT, _("&Print..."), _("Print cards from this set"));
|
||||
menuFile->AppendSeparator();
|
||||
// recent files go here
|
||||
menuFile->AppendSeparator();
|
||||
menuFile->Append(ID_FILE_EXIT, _("E&xit\tAlt+F4"), _("Quits Magic Set Editor; prompts to save the set"));
|
||||
menuBar->Append(menuFile, _("&File"));
|
||||
|
||||
IconMenu* menuEdit = new IconMenu();
|
||||
menuEdit->Append(ID_EDIT_UNDO, _("TOOL_UNDO"), _("&Undo\tCtrl+Z"), _("Undoes the last action"));
|
||||
menuEdit->Append(ID_EDIT_REDO, _("TOOL_REDO"), _("&Redo\tF4"), _("Redoes the last action"));
|
||||
menuEdit->AppendSeparator();
|
||||
menuEdit->Append(ID_EDIT_CUT, _("TOOL_CUT"), _("Cu&t\tCtrl+X"), _("Move the selected text to the clipboard"));
|
||||
menuEdit->Append(ID_EDIT_COPY, _("TOOL_COPY"), _("&Copy\tCtrl+C"), _("Place the selected text on the clipboard"));
|
||||
menuEdit->Append(ID_EDIT_PASTE, _("TOOL_PASTE"), _("&Paste\tCtrl+V"), _("Inserts the text from the clipboard"));
|
||||
menuEdit->AppendSeparator();
|
||||
menuEdit->Append(ID_EDIT_FIND, _("TOOL_FIND"), _("&Find...\tCtrl+F"), _(""));
|
||||
menuEdit->Append(ID_EDIT_FIND_NEXT, _("Find &Next\tF3"), _(""));
|
||||
menuEdit->Append(ID_EDIT_REPLACE, _("R&eplace...\tCtrl+H"), _(""));
|
||||
menuEdit->AppendSeparator();
|
||||
menuEdit->Append(ID_EDIT_PREFERENCES, _("Preferences..."), _("Change the configuration of Magic Set Editor"));
|
||||
menuBar->Append(menuEdit, _("&Edit"));
|
||||
|
||||
IconMenu* menuWindow = new IconMenu();
|
||||
menuWindow->Append(ID_WINDOW_NEW, _ ("&New Window"), _("Creates another window to edit the same set"));
|
||||
menuWindow->AppendSeparator();
|
||||
menuBar->Append(menuWindow, _("&Window"));
|
||||
|
||||
IconMenu* menuHelp = new IconMenu();
|
||||
menuHelp->Append(ID_HELP_INDEX, _("TOOL_HELP"), _("&Index..\tF1"), _(""));
|
||||
menuHelp->AppendSeparator();
|
||||
menuHelp->Append(ID_HELP_ABOUT, _("&About Magic Set Editor..."), _(""));
|
||||
menuBar->Append(menuHelp, _("&Help"));
|
||||
|
||||
SetMenuBar(menuBar);
|
||||
|
||||
// status bar
|
||||
CreateStatusBar();
|
||||
SetStatusText(_("Welcome to Magic Set Editor"));
|
||||
|
||||
// tool bar
|
||||
wxToolBar* tb = CreateToolBar(wxTB_FLAT | wxNO_BORDER | wxTB_HORIZONTAL);
|
||||
tb->AddTool(ID_FILE_NEW, _(""), Bitmap(_("TOOL_NEW")), wxNullBitmap, wxITEM_NORMAL, _("New set"), _("Creates a new set"));
|
||||
tb->AddTool(ID_FILE_OPEN, _(""), Bitmap(_("TOOL_OPEN")), wxNullBitmap, wxITEM_NORMAL, _("Open set"), _("Opens an existing set"));
|
||||
tb->AddTool(ID_FILE_SAVE, _(""), Bitmap(_("TOOL_SAVE")), wxNullBitmap, wxITEM_NORMAL, _("Save set"), _("Saves the current set"));
|
||||
tb->AddSeparator();
|
||||
tb->AddTool(ID_EDIT_CUT, _(""), Bitmap(_("TOOL_CUT")), wxNullBitmap, wxITEM_NORMAL, _("Cut"));
|
||||
tb->AddTool(ID_EDIT_COPY, _(""), Bitmap(_("TOOL_COPY")), wxNullBitmap, wxITEM_NORMAL, _("Copy"));
|
||||
tb->AddTool(ID_EDIT_PASTE, _(""), Bitmap(_("TOOL_PASTE")),wxNullBitmap, wxITEM_NORMAL, _("Paste"));
|
||||
tb->AddSeparator();
|
||||
tb->AddTool(ID_EDIT_UNDO, _(""), Bitmap(_("TOOL_UNDO")), wxNullBitmap, wxITEM_NORMAL, _("Undo"));
|
||||
tb->AddTool(ID_EDIT_REDO, _(""), Bitmap(_("TOOL_REDO")), wxNullBitmap, wxITEM_NORMAL, _("Redo"));
|
||||
tb->AddSeparator();
|
||||
tb->Realize();
|
||||
|
||||
// tab bar, sizer
|
||||
wxToolBar* tabBar = new wxToolBar(this, ID_TAB_BAR, wxDefaultPosition, wxDefaultSize, wxTB_FLAT | wxNO_BORDER | wxTB_HORIZONTAL | wxTB_HORZ_TEXT | wxTB_NOICONS);
|
||||
wxSizer* s = new wxBoxSizer(wxVERTICAL);
|
||||
s->Add(tabBar, 0, wxEXPAND | wxBOTTOM, 3);
|
||||
SetSizer(s);
|
||||
|
||||
// panels
|
||||
// NOTE: place the CardsPanel last in the panels list,
|
||||
// this way the card list is the last to be told of a set change
|
||||
// this way everyone else already uses the new set when it sends a CardSelectEvent
|
||||
// addPanel(menuWindow, tabBar, new CardsPanel (this, wxID_ANY), 4, _("F5"));
|
||||
// addPanel(menuWindow, tabBar, new SetInfoPanel (this, wxID_ANY), 0, _("F6"));
|
||||
// addPanel(menuWindow, tabBar, new StylePanel (this, wxID_ANY), 1, _("F7"));
|
||||
// addPanel(menuWindow, tabBar, new KeywordsPanel(this, wxID_ANY), 2, _("F8"));
|
||||
// addPanel(menuWindow, tabBar, new StatsPanel (this, wxID_ANY), 3, _("F9"));
|
||||
//addPanel(*s, *menuWindow, *tabBar, new DraftPanel (&this, wxID_ANY), 4, _("F10"))
|
||||
// selectPanel(idWindowMin + 4); // select cards panel
|
||||
|
||||
// loose ends
|
||||
tabBar->Realize();
|
||||
// setSize(settings.SetWindowWidth, settings.SetWindowHeight);
|
||||
// if (settings.SetWindowMaximized) {
|
||||
// maximize();
|
||||
// }
|
||||
// SetWindows.push_back(&this); // register this window
|
||||
// timer.owner = &this;
|
||||
// timer.start(10);
|
||||
// don't send update ui events to children
|
||||
// note: this still sends events for menu and toolbar items!
|
||||
wxUpdateUIEvent::SetMode(wxUPDATE_UI_PROCESS_SPECIFIED);
|
||||
SetExtraStyle(wxWS_EX_PROCESS_UI_UPDATES);
|
||||
}
|
||||
|
||||
SetWindow::~SetWindow() {
|
||||
// store window size in settings
|
||||
// wxSize s = getSize();
|
||||
// settings.SetWindowMaximized = isMaximized();
|
||||
// if (!isMaximized()) {
|
||||
// settings.SetWindowWidth = s.GetWidth();
|
||||
// settings.SetWindowHeight = s.GetHeight();
|
||||
// }
|
||||
// // destroy ui of selected panel
|
||||
// currentPanel->destroyUI(GetToolBar(), GetMenuBar());
|
||||
// cleanup (see find stuff)
|
||||
// delete findDialog;
|
||||
// remove from list of main windows
|
||||
// SetWindows.erase(remove(SetWindows.begin(), SetWindows.end(), &this));
|
||||
// stop updating
|
||||
onBeforeChangeSet();
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------- : Panel managment
|
||||
|
||||
void SetWindow::addPanel(wxMenu* windowMenu, wxToolBar* tabBar, SetWindowPanel* panel, UInt pos, const String& shortcut) {
|
||||
// insert in list
|
||||
if (panels.size() <= pos) panels.resize(pos + 1);
|
||||
panels[pos] = panel;
|
||||
// add to tab bar
|
||||
int id = ID_WINDOW_MIN + pos;
|
||||
tabBar->AddTool(id,panel->shortName(), wxNullBitmap, wxNullBitmap, wxITEM_CHECK, panel->longName(), panel->description());
|
||||
// add to menu bar
|
||||
windowMenu->AppendCheckItem(id, panel->longName() + _("\t") + shortcut, panel->description());
|
||||
// add to sizer
|
||||
GetSizer()->Add(panel, 1, wxEXPAND);
|
||||
}
|
||||
|
||||
void SetWindow::selectPanel(int id) {
|
||||
SetWindowPanel* toSelect = panels.at(id - ID_WINDOW_MIN);
|
||||
if (currentPanel != toSelect) {
|
||||
// destroy & create menus
|
||||
if (currentPanel) currentPanel->destroyUI(GetToolBar(), GetMenuBar());
|
||||
currentPanel = toSelect;
|
||||
currentPanel->initUI(GetToolBar(), GetMenuBar());
|
||||
}
|
||||
// show/hide panels and select tabs
|
||||
wxSizer* sizer = GetSizer();
|
||||
wxToolBar* tabBar = (wxToolBar*)FindWindow(ID_TAB_BAR);
|
||||
wxMenuBar* menuBar = GetMenuBar();
|
||||
int wid = ID_WINDOW_MIN;
|
||||
FOR_EACH(p, panels) {
|
||||
sizer->Show (p, p == currentPanel);
|
||||
tabBar->ToggleTool(wid, p == currentPanel);
|
||||
menuBar->Check (wid, p == currentPanel);
|
||||
++wid;
|
||||
}
|
||||
// fix sizer stuff
|
||||
Layout();
|
||||
fixMinWindowSize();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Set actions
|
||||
|
||||
void SetWindow::onBeforeChangeSet() {
|
||||
// Make sure we don't own the set's scriptUpdater
|
||||
// if (set->scriptUpdater != &scriptUpdater) {
|
||||
// assert(!scriptUpdater.set);
|
||||
// return;
|
||||
// }
|
||||
// We do own the set's scriptUpdater
|
||||
// stop handling updates for the set
|
||||
// do this first, so events get send, which stop worker threads
|
||||
// scriptUpdater.setNullSet();
|
||||
// another window should take over the scriptUpdating
|
||||
// FOR_EACH(wnd, SetWindows) {
|
||||
// if (wnd != &this && wnd->getSet() == set) {
|
||||
// wnd->scriptUpdater.setSet(set);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
void SetWindow::onChangeSet() {
|
||||
// make sure there is always at least one card
|
||||
// some things need this
|
||||
if (set->cards.empty()) set->cards.push_back(new_shared1<Card>(*set->game));
|
||||
// does the set need a scriptUpdater? If so, we can do it
|
||||
// if (!set->scriptUpdater) scriptUpdater.set = set;
|
||||
// all panels view the same set
|
||||
FOR_EACH(p, panels) {
|
||||
p->setSet(set);
|
||||
}
|
||||
fixMinWindowSize();
|
||||
}
|
||||
|
||||
void SetWindow::onAction(const Action& action) {
|
||||
// TYPE_CASE_(action, SetStyleChange) {
|
||||
// // The style changed, maybe also the size of the viewer
|
||||
// Layout();
|
||||
// fixMinWindowSize();
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
void SetWindow::onCardSelect(wxCommandEvent& ev) {
|
||||
// CardP card = static_cast<CardSelectEvent&>(ev).card;
|
||||
// FOR_EACH(p, panels) {
|
||||
// p->selectCard(card);
|
||||
// }
|
||||
fixMinWindowSize();
|
||||
}
|
||||
|
||||
void SetWindow::onRenderSettingsChange() {
|
||||
FOR_EACH(p, panels) {
|
||||
p->onRenderSettingsChange();
|
||||
}
|
||||
Layout();
|
||||
fixMinWindowSize();
|
||||
}
|
||||
|
||||
void SetWindow::fixMinWindowSize() {
|
||||
wxSize s = GetSizer()->GetMinSize();
|
||||
wxSize ws = GetSize();
|
||||
wxSize cs = GetClientSize();
|
||||
wxSize minSize = wxSize(s.x + ws.x - cs.x, s.y + ws.y - cs.y);
|
||||
if (ws.x < minSize.x) ws.x = minSize.x;
|
||||
if (ws.y < minSize.y) ws.y = minSize.y;
|
||||
SetSize(ws);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------- : Window events - close
|
||||
|
||||
void SetWindow::onClose(wxCloseEvent& ev) {
|
||||
// only ask if we want to save is this is the only window that has the current set opened
|
||||
// if (!isOnlyWithSet() || askSaveAndContinue()) {
|
||||
// timer.stop();
|
||||
Destroy();
|
||||
// } else {
|
||||
// ev.Veto();
|
||||
// }
|
||||
}
|
||||
|
||||
bool SetWindow::askSaveAndContinue() {
|
||||
if (set->actions.atSavePoint()) return true;
|
||||
// todo : if more then one window has the set selected it's ok to proceed
|
||||
int save = wxMessageBox(_("The set has changed\n\nDo you want to save the changes?"), _("Save changes"), wxYES_NO | wxCANCEL | wxICON_EXCLAMATION);
|
||||
if (save == wxYES) {
|
||||
// save the set
|
||||
/* try {
|
||||
if (set->needSaveAs()) {
|
||||
// need save as
|
||||
FileDialog dlg(&this, _("Save a set"), _(""), _(""), exportFormats(set->game), wxSAVE | wxOVERWRITE_PROMPT);
|
||||
if (dlg.showModal() == wxID_OK) {
|
||||
exportSet(set, dlg.path, dlg.filterIndex);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
set->save();
|
||||
set->actions.atSavePoint = true;
|
||||
return true;
|
||||
}
|
||||
} catch (Error e) {
|
||||
// something went wrong with saving, don't proceed
|
||||
handleError(e);
|
||||
return false;
|
||||
}
|
||||
*/ return false;/////<<<<removeme
|
||||
} else if (save == wxNO) {
|
||||
return true;
|
||||
} else { // wxCANCEL
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Window events - update UI
|
||||
|
||||
void SetWindow::onUpdateUI(wxUpdateUIEvent& ev) {
|
||||
switch (ev.GetId()) {
|
||||
// file menu
|
||||
case ID_FILE_SAVE_AS: ev.Enable(!set->actions.atSavePoint() || set->needSaveAs()); break;
|
||||
case ID_FILE_EXPORT_IMAGE: ev.Enable(!!currentPanel->selectedCard()); break;
|
||||
case ID_FILE_EXPORT_APPR: ev.Enable(set->game->isMagic()); break;
|
||||
case ID_FILE_EXPORT_MWS: ev.Enable(set->game->isMagic()); break;
|
||||
/*case ID_FILE_INSPECT: {
|
||||
// the item just before FileRecent, because FileRecent may not be in the menu yet
|
||||
//updateRecentSets();
|
||||
// TODO
|
||||
break;
|
||||
}*/
|
||||
// undo/redo
|
||||
case ID_EDIT_UNDO: {
|
||||
ev.Enable(set->actions.canUndo());
|
||||
String label = set->actions.undoName();
|
||||
ev.SetText(label + _("\tCtrl+Z"));
|
||||
GetToolBar()->SetToolShortHelp(ID_EDIT_UNDO, label);
|
||||
break;
|
||||
} case ID_EDIT_REDO: {
|
||||
ev.Enable(set->actions.canRedo());
|
||||
String label = set->actions.redoName();
|
||||
ev.SetText(label + _("\tF4"));
|
||||
GetToolBar()->SetToolShortHelp(ID_EDIT_REDO, label);
|
||||
break;
|
||||
}
|
||||
// copy & paste & find
|
||||
case ID_EDIT_CUT : ev.Enable(currentPanel->canCut()); break;
|
||||
case ID_EDIT_COPY : ev.Enable(currentPanel->canCopy()); break;
|
||||
case ID_EDIT_PASTE : ev.Enable(currentPanel->canPaste()); break;
|
||||
case ID_EDIT_FIND : ev.Enable(currentPanel->canFind()); break;
|
||||
case ID_EDIT_FIND_NEXT : ev.Enable(currentPanel->canFind()); break;
|
||||
case ID_EDIT_REPLACE : ev.Enable(currentPanel->canReplace()); break;
|
||||
default:
|
||||
// items created by the panel, and cut/copy/paste and find/replace
|
||||
currentPanel->onUpdateUI(ev);
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Window events - menu - file
|
||||
|
||||
|
||||
void SetWindow::onFileNew(wxCommandEvent&) {
|
||||
if (!askSaveAndContinue()) return;
|
||||
// NewWindow wnd(this);
|
||||
// wnd.showModal();
|
||||
// associate new set
|
||||
// if (wnd.set) set = wnd.set;
|
||||
}
|
||||
|
||||
void SetWindow::onFileOpen(wxCommandEvent&) {
|
||||
if (!askSaveAndContinue()) return;
|
||||
wxFileDialog dlg(this, _("Open a set"), _(""), _(""), importFormats(), wxOPEN);
|
||||
if (dlg.ShowModal() == wxID_OK) {
|
||||
set = importSet(dlg.GetPath());
|
||||
}
|
||||
}
|
||||
|
||||
void SetWindow::onFileSave(wxCommandEvent& ev) {
|
||||
if (set->needSaveAs()) {
|
||||
onFileSaveAs(ev);
|
||||
} else {
|
||||
settings.addRecentFile(set->absoluteFilename());
|
||||
set->save();
|
||||
set->actions.setSavePoint();
|
||||
}
|
||||
}
|
||||
|
||||
void SetWindow::onFileSaveAs(wxCommandEvent&) {
|
||||
wxFileDialog dlg(this, _("Save a set"), _(""), _(""), exportFormats(*set->game), wxSAVE | wxOVERWRITE_PROMPT);
|
||||
if (dlg.ShowModal() == wxID_OK) {
|
||||
exportSet(*set, dlg.GetPath(), dlg.GetFilterIndex());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void SetWindow::onFileInspect(wxCommandEvent&) {
|
||||
var wnd = new TreeGridWindow(&this, set);
|
||||
wnd.show();
|
||||
}*/
|
||||
|
||||
void SetWindow::onFileExportImage(wxCommandEvent&) {
|
||||
CardP card = currentPanel->selectedCard();
|
||||
if (!card) return; // no card selected
|
||||
String name = wxFileSelector(_("Save image"), _(""), card->identification(), _(""),
|
||||
_("JPEG images (*.jpg)|*.jpg|Windows bitmaps (*.bmp)|*.bmp|PNG images (*.png)|*.png|GIF images (*.gif)|*.gif|TIFF images (*.tif)|*.tif"),
|
||||
wxSAVE | wxOVERWRITE_PROMPT, this);
|
||||
if (!name.empty()) {
|
||||
// exportImage(set, card, name);
|
||||
}
|
||||
}
|
||||
|
||||
void SetWindow::onFileExportImages(wxCommandEvent&) {
|
||||
// exportImages(this, set);
|
||||
}
|
||||
|
||||
void SetWindow::onFileExportHTML(wxCommandEvent&) {
|
||||
// HtmlExportWindow wnd(&this, set);
|
||||
// wnd.ShowModal();
|
||||
/*;//%%
|
||||
String name = fileSelector(_("Exort to html"),_(""),_(""),_(""), {
|
||||
_("HTML files (*.html)|*.html"),
|
||||
wxSAVE | wxOVERWRITE_PROMPT);
|
||||
}
|
||||
if (!name.empty()) {
|
||||
HtmlExportWindow wnd(&this, set, name);
|
||||
wnd.showModal();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void SetWindow::onFileExportApprentice(wxCommandEvent&) {
|
||||
// ApprenticeExportWindow wnd(&this, set);
|
||||
// wnd.ShowModal();
|
||||
}
|
||||
|
||||
void SetWindow::onFileExportMWS(wxCommandEvent&) {
|
||||
// exportMWS(set);
|
||||
}
|
||||
|
||||
void SetWindow::onFilePrint(wxCommandEvent&) {
|
||||
// printSet(this, set);
|
||||
}
|
||||
|
||||
void SetWindow::onFilePrintPreview(wxCommandEvent&) {
|
||||
// printPreview(this, set);
|
||||
}
|
||||
|
||||
void SetWindow::onFileRecent(wxCommandEvent& ev) {
|
||||
// setSet(importSet(settings.recentSets.at(ev.GetId() - ID_FILE_RECENT)));
|
||||
}
|
||||
|
||||
void SetWindow::onFileExit(wxCommandEvent&) {
|
||||
Close();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Window events - menu - edit
|
||||
|
||||
void SetWindow::onEditUndo(wxCommandEvent&) {
|
||||
set->actions.undo();
|
||||
}
|
||||
void SetWindow::onEditRedo(wxCommandEvent&) {
|
||||
set->actions.redo();
|
||||
}
|
||||
|
||||
void SetWindow::onEditCut (wxCommandEvent&) {
|
||||
currentPanel->doCut();
|
||||
}
|
||||
void SetWindow::onEditCopy (wxCommandEvent&) {
|
||||
currentPanel->doCopy();
|
||||
}
|
||||
void SetWindow::onEditPaste(wxCommandEvent&) {
|
||||
currentPanel->doPaste();
|
||||
}
|
||||
|
||||
void SetWindow::onEditFind(wxCommandEvent&) {
|
||||
delete findDialog;
|
||||
findDialog = new wxFindReplaceDialog(this, &findData, _("Find"));
|
||||
findDialog->Show();
|
||||
}
|
||||
void SetWindow::onEditFindNext(wxCommandEvent&) {
|
||||
currentPanel->doFind(findData);
|
||||
}
|
||||
void SetWindow::onEditReplace(wxCommandEvent&) {
|
||||
delete findDialog;
|
||||
findDialog = new wxFindReplaceDialog(this, &findData, _("Replace"), wxFR_REPLACEDIALOG);
|
||||
findDialog->Show();
|
||||
}
|
||||
|
||||
// find events
|
||||
void SetWindow::onFind (wxFindDialogEvent&) {
|
||||
currentPanel->doFind(findData);
|
||||
}
|
||||
void SetWindow::onFindNext (wxFindDialogEvent&) {
|
||||
currentPanel->doFind(findData);
|
||||
}
|
||||
void SetWindow::onReplace (wxFindDialogEvent&) {
|
||||
currentPanel->doReplace(findData);
|
||||
}
|
||||
void SetWindow::onReplaceAll(wxFindDialogEvent&) {
|
||||
// todo
|
||||
}
|
||||
|
||||
void SetWindow::onEditPreferences(wxCommandEvent&) {
|
||||
// SettingsWindow wnd(this);
|
||||
// if (wnd.ShowModal() == wxID_OK) {
|
||||
// // render settings may have changed, notify all windows
|
||||
// FOR_EACH(m, setWindows) {
|
||||
// m->onRenderSettingsChange();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------- : Window events - menu - window
|
||||
|
||||
void SetWindow::onWindowNewWindow(wxCommandEvent&) {
|
||||
SetWindow* newWindow = new SetWindow(nullptr);
|
||||
newWindow->setSet(set);
|
||||
newWindow->Show();
|
||||
}
|
||||
|
||||
void SetWindow::onWindowSelect(wxCommandEvent& ev) {
|
||||
selectPanel(ev.GetId());
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------- : Window events - menu - help
|
||||
|
||||
void SetWindow::onHelpIndex(wxCommandEvent&) {
|
||||
// TODO : context sensitive
|
||||
// HelpWindow* wnd = new HelpWindow(this);
|
||||
// wnd->Show();
|
||||
}
|
||||
|
||||
void SetWindow::onHelpAbout(wxCommandEvent&) {
|
||||
// AboutWindow wnd(this);
|
||||
// wnd.ShowModal();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Window events - menu - for child panel
|
||||
|
||||
void SetWindow::onChildMenu(wxCommandEvent& ev) {
|
||||
currentPanel->onCommand(ev.GetId());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Event table
|
||||
|
||||
BEGIN_EVENT_TABLE(SetWindow, wxFrame)
|
||||
EVT_MENU (ID_FILE_NEW, SetWindow::onFileNew)
|
||||
EVT_MENU (ID_FILE_OPEN, SetWindow::onFileOpen)
|
||||
EVT_MENU (ID_FILE_SAVE, SetWindow::onFileSave)
|
||||
EVT_MENU (ID_FILE_SAVE_AS, SetWindow::onFileSaveAs)
|
||||
EVT_MENU (ID_FILE_EXPORT_IMAGE, SetWindow::onFileExportImage)
|
||||
EVT_MENU (ID_FILE_EXPORT_IMAGES, SetWindow::onFileExportImages)
|
||||
EVT_MENU (ID_FILE_EXPORT_HTML, SetWindow::onFileExportHTML)
|
||||
EVT_MENU (ID_FILE_EXPORT_APPR, SetWindow::onFileExportApprentice)
|
||||
EVT_MENU (ID_FILE_EXPORT_MWS, SetWindow::onFileExportMWS)
|
||||
// EVT_MENU (ID_FILE_INSPECT, SetWindow::onFileInspect)
|
||||
EVT_MENU (ID_FILE_PRINT, SetWindow::onFilePrint)
|
||||
EVT_MENU (ID_FILE_PRINT_PREVIEW, SetWindow::onFilePrintPreview)
|
||||
EVT_MENU_RANGE (ID_FILE_RECENT, ID_FILE_RECENT_MAX, SetWindow::onFileRecent)
|
||||
EVT_MENU (ID_FILE_EXIT, SetWindow::onFileExit)
|
||||
EVT_MENU (ID_EDIT_UNDO, SetWindow::onEditUndo)
|
||||
EVT_MENU (ID_EDIT_REDO, SetWindow::onEditRedo)
|
||||
EVT_MENU (ID_EDIT_CUT, SetWindow::onEditCut)
|
||||
EVT_MENU (ID_EDIT_COPY, SetWindow::onEditCopy)
|
||||
EVT_MENU (ID_EDIT_PASTE, SetWindow::onEditPaste)
|
||||
EVT_MENU (ID_EDIT_FIND, SetWindow::onEditFind)
|
||||
EVT_MENU (ID_EDIT_FIND_NEXT, SetWindow::onEditFindNext)
|
||||
EVT_MENU (ID_EDIT_REPLACE, SetWindow::onEditReplace)
|
||||
EVT_MENU (ID_EDIT_PREFERENCES, SetWindow::onEditPreferences)
|
||||
EVT_MENU (ID_WINDOW_NEW, SetWindow::onWindowNewWindow)
|
||||
EVT_TOOL_RANGE (ID_WINDOW_MIN, ID_WINDOW_MAX, SetWindow::onWindowSelect)
|
||||
EVT_MENU (ID_HELP_INDEX, SetWindow::onHelpIndex)
|
||||
EVT_MENU (ID_HELP_ABOUT, SetWindow::onHelpAbout)
|
||||
EVT_TOOL_RANGE (ID_CHILD_MIN, ID_CHILD_MAX, SetWindow::onChildMenu)
|
||||
|
||||
EVT_UPDATE_UI (wxID_ANY, SetWindow::onUpdateUI)
|
||||
// EVT_FIND (wxID_ANY, SetWindow::onFind)
|
||||
// EVT_FIND_NEXT (wxID_ANY, SetWindow::onFindNext)
|
||||
// EVT_FIND_REPLACE (wxID_ANY, SetWindow::onReplace)
|
||||
// EVT_FIND_REPLACE_ALL(wxID_ANY, SetWindow::onReplaceAll)
|
||||
EVT_CLOSE ( SetWindow::onClose)
|
||||
// EVT_TIMER (wxID_ANY, SetWindow::onTick)
|
||||
// EVT_IDLE ( SetWindow::onIdle)
|
||||
// EVT_CARD_SELECT (wxID_ANY, SetWindow::onCardSelect)
|
||||
END_EVENT_TABLE ()
|
||||
@@ -0,0 +1,158 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
|
||||
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
|
||||
//| License: GNU General Public License 2 or later (see file COPYING) |
|
||||
//+----------------------------------------------------------------------------+
|
||||
|
||||
#ifndef HEADER_GUI_SET_WINDOW
|
||||
#define HEADER_GUI_SET_WINDOW
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <data/set.hpp>
|
||||
#include <wx/fdrepdlg.h>
|
||||
|
||||
class IconMenu;
|
||||
class SetWindowPanel;
|
||||
class wxFindDialogEvent;
|
||||
|
||||
// ----------------------------------------------------------------------------- : SetWindow
|
||||
|
||||
/// The main window of MSE, used for editing Sets.
|
||||
/** This window consists of several panels, only one panel is visible at a time.
|
||||
*/
|
||||
class SetWindow : public wxFrame, public SetView {
|
||||
public:
|
||||
/// Construct a SetWindow
|
||||
SetWindow(Window* parent);
|
||||
~SetWindow();
|
||||
|
||||
// --------------------------------------------------- : Set actions
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE();
|
||||
|
||||
// --------------------------------------------------- : Data
|
||||
|
||||
// keep scripts up to date
|
||||
// ScriptUpdater scriptUpdater;
|
||||
// Timer timer;
|
||||
|
||||
// gui items
|
||||
vector<SetWindowPanel*> panels; ///< All panels on this window
|
||||
SetWindowPanel* currentPanel;
|
||||
|
||||
/// Number of items in the recent sets list
|
||||
size_t numberOfRecentSets;
|
||||
|
||||
// data for find/replace
|
||||
wxDialog* findDialog;
|
||||
wxFindReplaceData findData;
|
||||
|
||||
// --------------------------------------------------- : Panel managment
|
||||
|
||||
/// Add a panel to the window, as well as to the menu and tab bar
|
||||
/** The position only determines the order in which events will be send.
|
||||
*/
|
||||
void addPanel(wxMenu* windowMenu, wxToolBar* tabBar, SetWindowPanel* panel, UInt pos, const String& shortcut);
|
||||
|
||||
/// Select a panel, based on a tab id
|
||||
void selectPanel(int id);
|
||||
|
||||
// --------------------------------------------------- : Managing multiple main windows
|
||||
|
||||
/// All opened main windows
|
||||
static vector<SetWindow*> setWindows;
|
||||
|
||||
/// Is this the first window that has this set?
|
||||
/** The first window is considered the owner in many cases */
|
||||
bool isFirstWithSet();
|
||||
|
||||
/// Is this the only window that has this set?
|
||||
bool isOnlyWithSet();
|
||||
|
||||
// --------------------------------------------------- : Action related
|
||||
protected:
|
||||
/// We want to respond to set changes
|
||||
virtual void onBeforeChangeSet();
|
||||
/// We want to respond to set changes
|
||||
virtual void onChangeSet();
|
||||
/// Actions that change the set
|
||||
virtual void onAction(const Action&);
|
||||
|
||||
private:
|
||||
/// A different card has been selected
|
||||
void onCardSelect(wxCommandEvent&);
|
||||
|
||||
/// Render settings have changed (because of editing of preferences)
|
||||
void onRenderSettingsChange();
|
||||
|
||||
// minSize = mainSizer->getMinWindowSize(this)
|
||||
// but wx made that private
|
||||
void fixMinWindowSize();
|
||||
|
||||
// --------------------------------------------------- : Window events - close
|
||||
|
||||
/// Ask the user to save the set
|
||||
void onClose(wxCloseEvent&);
|
||||
|
||||
/// Ask if the user wants to save the set
|
||||
/** Returns true if the action can be continued (the set was saved, or need not be saved)
|
||||
* Returns false if the action should be canceled (user pressed cancel, or save failed)
|
||||
*/
|
||||
bool askSaveAndContinue();
|
||||
|
||||
// --------------------------------------------------- : Window events - update UI
|
||||
|
||||
void onUpdateUI(wxUpdateUIEvent&);
|
||||
|
||||
// --------------------------------------------------- : Window events - menu - file
|
||||
void onFileNew (wxCommandEvent&);
|
||||
void onFileOpen (wxCommandEvent&);
|
||||
void onFileSave (wxCommandEvent&);
|
||||
void onFileSaveAs (wxCommandEvent&);
|
||||
// void onFileInspect (wxCommandEvent&);
|
||||
void onFileExportImage (wxCommandEvent&);
|
||||
void onFileExportImages (wxCommandEvent&);
|
||||
void onFileExportHTML (wxCommandEvent&);
|
||||
void onFileExportApprentice(wxCommandEvent&);
|
||||
void onFileExportMWS (wxCommandEvent&);
|
||||
void onFilePrint (wxCommandEvent&);
|
||||
void onFilePrintPreview (wxCommandEvent&);
|
||||
void onFileRecent (wxCommandEvent&);
|
||||
void onFileExit (wxCommandEvent&);
|
||||
|
||||
// --------------------------------------------------- : Window events - menu - edit
|
||||
|
||||
void onEditUndo (wxCommandEvent&);
|
||||
void onEditRedo (wxCommandEvent&);
|
||||
void onEditCut (wxCommandEvent&);
|
||||
void onEditCopy (wxCommandEvent&);
|
||||
void onEditPaste (wxCommandEvent&);
|
||||
void onEditFind (wxCommandEvent&);
|
||||
void onEditFindNext (wxCommandEvent&);
|
||||
void onEditReplace (wxCommandEvent&);
|
||||
void onEditPreferences (wxCommandEvent&);
|
||||
|
||||
void onFind (wxFindDialogEvent&);
|
||||
void onFindNext (wxFindDialogEvent&);
|
||||
void onReplace (wxFindDialogEvent&);
|
||||
void onReplaceAll (wxFindDialogEvent&);
|
||||
|
||||
// --------------------------------------------------- : Window events - menu - window
|
||||
|
||||
void onWindowNewWindow (wxCommandEvent&);
|
||||
void onWindowSelect (wxCommandEvent&);
|
||||
// --------------------------------------------------- : Window events - menu - help
|
||||
|
||||
void onHelpIndex (wxCommandEvent&);
|
||||
void onHelpAbout (wxCommandEvent&);
|
||||
|
||||
// --------------------------------------------------- : Window events - menu - for child panel
|
||||
|
||||
void onChildMenu (wxCommandEvent&);
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
#endif
|
||||
@@ -44,7 +44,7 @@ class SymbolEditorBase {
|
||||
// --------------------------------------------------- : UI
|
||||
|
||||
/// Init extra toolbar items and menus needed for this editor
|
||||
virtual void initUI(wxToolBar* tb, wxMenuBar* mb) {}
|
||||
virtual void initUI (wxToolBar* tb, wxMenuBar* mb) {}
|
||||
/// Destroy the extra items added by initUI.
|
||||
virtual void destroyUI(wxToolBar* tb, wxMenuBar* mb) {}
|
||||
/// Update the UI by enabling/disabling items
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include <util/window_id.hpp>
|
||||
#include <util/error.hpp>
|
||||
|
||||
DECLARE_TYPEOF_COLLECTION(ControlPointP);
|
||||
|
||||
// ----------------------------------------------------------------------------- : SymbolPointEditor
|
||||
|
||||
SymbolPointEditor::SymbolPointEditor(SymbolControl* control, const SymbolPartP& part)
|
||||
|
||||
@@ -57,7 +57,7 @@ class SymbolPointEditor : public SymbolEditorBase {
|
||||
public:
|
||||
// --------------------------------------------------- : UI
|
||||
|
||||
virtual void initUI(wxToolBar* tb, wxMenuBar* mb);
|
||||
virtual void initUI (wxToolBar* tb, wxMenuBar* mb);
|
||||
virtual void destroyUI(wxToolBar* tb, wxMenuBar* mb);
|
||||
virtual void onUpdateUI(wxUpdateUIEvent& e);
|
||||
virtual void onCommand(int id);
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include <data/action/symbol.hpp>
|
||||
#include <gfx/gfx.hpp>
|
||||
|
||||
DECLARE_TYPEOF_COLLECTION(SymbolPartP);
|
||||
|
||||
// ----------------------------------------------------------------------------- : SymbolSelectEditor
|
||||
|
||||
SymbolSelectEditor::SymbolSelectEditor(SymbolControl* control, bool rotate)
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#include <gui/symbol/viewer.hpp>
|
||||
|
||||
DECLARE_TYPEOF_COLLECTION(SymbolPartP);
|
||||
|
||||
// ----------------------------------------------------------------------------- : Constructor
|
||||
|
||||
SymbolViewer::SymbolViewer(const SymbolP& symbol, double borderRadius)
|
||||
|
||||
@@ -77,7 +77,7 @@ void SymbolWindow::init(Window* parent, SymbolP symbol) {
|
||||
menuTool->Append(ID_MODE_SHAPES, _("TOOL_CIRCLE"), _("&Basic Shapes\tF8"), _("Draw basic shapes, such as rectangles and circles"), wxITEM_CHECK);
|
||||
menuTool->Append(ID_MODE_PAINT, _("TOOL_MODE_PAINT"), _("P&aint\tF9"), _("Paint on the shape using a paintbrush"), wxITEM_CHECK);
|
||||
menuBar->Append(menuTool, _("&Tool"));
|
||||
|
||||
|
||||
SetMenuBar(menuBar);
|
||||
|
||||
// Statusbar
|
||||
|
||||
Reference in New Issue
Block a user