added native look editor and the set info panel

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@82 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2006-11-20 17:26:34 +00:00
parent 141400d8aa
commit 3cbf2577c1
32 changed files with 458 additions and 48 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ class CardsPanel : public SetWindowPanel {
~CardsPanel();
void onChangeSet();
// --------------------------------------------------- : UI
virtual void initUI (wxToolBar* tb, wxMenuBar* mb);
+67
View File
@@ -7,10 +7,77 @@
// ----------------------------------------------------------------------------- : Includes
#include <gui/set/set_info_panel.hpp>
#include <gui/control/native_look_editor.hpp>
#include <gui/icon_menu.hpp>
#include <util/window_id.hpp>
// ----------------------------------------------------------------------------- : SetInfoPanel
SetInfoPanel::SetInfoPanel(Window* parent, int id)
: SetWindowPanel(parent, id)
{
// init controls
editor = new SetInfoEditor(this, wxID_ANY);
// init sizer
wxSizer* s = new wxBoxSizer(wxVERTICAL);
s->Add(editor, 1, wxEXPAND, 2);
s->SetSizeHints(this);
SetSizer(s);
}
void SetInfoPanel::onChangeSet() {
editor->setSet(set);
}
// ----------------------------------------------------------------------------- : UI
void SetInfoPanel::initUI(wxToolBar* tb, wxMenuBar* mb) {
// Toolbar
tb->AddTool(ID_FORMAT_BOLD, _(""), Bitmap(_("TOOL_BOLD")), wxNullBitmap, wxITEM_CHECK, _("Bold"));
tb->AddTool(ID_FORMAT_ITALIC, _(""), Bitmap(_("TOOL_ITALIC")), wxNullBitmap, wxITEM_CHECK, _("Italic"));
tb->AddTool(ID_FORMAT_SYMBOL, _(""), Bitmap(_("TOOL_SYMBOL")), wxNullBitmap, wxITEM_CHECK, _("Symbols"));
tb->Realize();
// Menus
IconMenu* menuFormat = new IconMenu();
menuFormat->Append(ID_FORMAT_BOLD, _("TOOL_BOLD"), _("Bold\tCtrl+B"), _("Makes the selected text bold"), wxITEM_CHECK);
menuFormat->Append(ID_FORMAT_ITALIC, _("TOOL_ITALIC"), _("Italic\tCtrl+I"), _("Makes the selected text italic"), wxITEM_CHECK);
menuFormat->Append(ID_FORMAT_SYMBOL, _("TOOL_SYMBOL"), _("Symbols\tCtrl+M"), _("Draws the selected text with symbols"), wxITEM_CHECK);
menuFormat->Append(ID_FORMAT_REMINDER, _("TOOL_REMINDER"), _("Reminder Text\tCtrl+R"), _("Show reminder text for the selected keyword"), wxITEM_CHECK);
mb->Insert(2, menuFormat, _("&Format"));
}
void SetInfoPanel::destroyUI(wxToolBar* tb, wxMenuBar* mb) {
// Toolbar
tb->DeleteTool(ID_FORMAT_BOLD);
tb->DeleteTool(ID_FORMAT_ITALIC);
tb->DeleteTool(ID_FORMAT_SYMBOL);
// Menus
delete mb->Remove(2);
}
void SetInfoPanel::onUpdateUI(wxUpdateUIEvent& e) {
switch (e.GetId()) {
case ID_FORMAT_BOLD: case ID_FORMAT_ITALIC: case ID_FORMAT_SYMBOL: {
e.Enable(editor->canFormat(e.GetId()));
e.Check (editor->hasFormat(e.GetId()));
break;
}
}
}
void SetInfoPanel::onCommand(int id) {
switch (id) {
case ID_FORMAT_BOLD: case ID_FORMAT_ITALIC: case ID_FORMAT_SYMBOL: {
editor->doFormat(id);
}
}
}
// ----------------------------------------------------------------------------- : Clipboard
bool SetInfoPanel::canCut() const { return editor->canCut(); }
bool SetInfoPanel::canCopy() const { return editor->canCopy(); }
bool SetInfoPanel::canPaste() const { return editor->canPaste(); }
void SetInfoPanel::doCut() { editor->doCut(); }
void SetInfoPanel::doCopy() { editor->doCopy(); }
void SetInfoPanel::doPaste() { editor->doPaste(); }
+24
View File
@@ -12,11 +12,35 @@
#include <util/prec.hpp>
#include <gui/set/panel.hpp>
class SetInfoEditor;
// ----------------------------------------------------------------------------- : SetInfoPanel
class SetInfoPanel : public SetWindowPanel {
public:
SetInfoPanel(Window* parent, int id);
// --------------------------------------------------- : 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);
// --------------------------------------------------- : Clipboard
virtual bool canCut() const;
virtual bool canCopy() const;
virtual bool canPaste() const;
virtual void doCut();
virtual void doCopy();
virtual void doPaste();
protected:
virtual void onChangeSet();
private:
SetInfoEditor* editor;
};
// ----------------------------------------------------------------------------- : EOF
+6 -11
View File
@@ -116,16 +116,13 @@ SetWindow::SetWindow(Window* parent, const SetP& set)
// 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), 2, _("F5"), _("Cards"), _("Cards"), _("Edit the cards in the set"));
// addPanel(menuWindow, tabBar, new SetInfoPanel (this, wxID_ANY), 0, _("F6"));
addPanel(menuWindow, tabBar, new StylePanel (this, wxID_ANY), 1, _("F7"), _("Style"), _("Style"), _("Change the style of cards"));
addPanel(menuWindow, tabBar, new CardsPanel (this, wxID_ANY), 3, _("F5"), _("Cards"), _("Cards"), _("Edit the cards in the set"));
addPanel(menuWindow, tabBar, new SetInfoPanel (this, wxID_ANY), 0, _("F6"), _("Set info"), _("&Set Information"), _("Edit information about the set, its creator, etc."));
addPanel(menuWindow, tabBar, new StylePanel (this, wxID_ANY), 1, _("F7"), _("Style"), _("Style"), _("Change the style of cards"));
// addPanel(menuWindow, tabBar, new KeywordsPanel(this, wxID_ANY), 2, _("F8"));
// addPanel(menuWindow, tabBar, new StatsPanel (this, wxID_ANY), 3, _("F9"), _("Stats"), _("Statistics"), _("Show statistics about the cards in the set"));
//addPanel(*s, *menuWindow, *tabBar, new DraftPanel (&this, wxID_ANY), 4, _("F10"))
// selectPanel(idWindowMin + 4); // select cards panel
addPanel(menuWindow, tabBar, new StatsPanel (this, wxID_ANY), 0, _("F9"), _("Stats"), _("Statistics"), _("Show statistics about the cards in the set"));
selectPanel(ID_WINDOW_MIN+2); // test
addPanel(menuWindow, tabBar, new StatsPanel (this, wxID_ANY), 2, _("F9"), _("Stats"), _("Statistics"), _("Show statistics about the cards in the set"));
// addPanel(*s, *menuWindow, *tabBar, new DraftPanel (&this, wxID_ANY), 4, _("F10"))
selectPanel(ID_WINDOW_MIN + 3); // select cards panel
// loose ends
tabBar->Realize();
@@ -227,8 +224,6 @@ 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);