Added dummy CardEditor, implemented Stylesheet loading

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@50 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2006-10-26 22:46:28 +00:00
parent c8e8dd0220
commit 1459cd6d76
23 changed files with 252 additions and 42 deletions
+21
View File
@@ -0,0 +1,21 @@
//+----------------------------------------------------------------------------+
//| 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/control/card_editor.hpp>
// ----------------------------------------------------------------------------- : DataEditor
DataEditor::DataEditor(Window* parent, int id, long style)
: CardViewer(parent, id, style)
{}
// ----------------------------------------------------------------------------- : Event table
BEGIN_EVENT_TABLE(DataEditor, CardViewer)
END_EVENT_TABLE ()
+29
View File
@@ -0,0 +1,29 @@
//+----------------------------------------------------------------------------+
//| 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_CONTROL_CARD_EDITOR
#define HEADER_GUI_CONTROL_CARD_EDITOR
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <gui/control/card_viewer.hpp>
// ----------------------------------------------------------------------------- : DataEditor
/// An editor for data values (usually a card)
class DataEditor : public CardViewer {
public:
DataEditor(Window* parent, int id, long style = 0);
private:
DECLARE_EVENT_TABLE();
};
/// By default a DataEditor edits cards
typedef DataEditor CardEditor;
// ----------------------------------------------------------------------------- : EOF
#endif
+6 -2
View File
@@ -12,13 +12,17 @@
// ----------------------------------------------------------------------------- : CardViewer
CardViewer::CardViewer(Window* parent, int id, int style)
CardViewer::CardViewer(Window* parent, int id, long style)
: wxControl(parent, id, wxDefaultPosition, wxDefaultSize, style)
{}
wxSize CardViewer::DoGetBestSize() const {
wxSize ws = GetSize(), cs = GetClientSize();
return wxSize(set->stylesheet->card_width, set->stylesheet->card_height) + ws - cs;
if (set && set->stylesheet) {
return wxSize(set->stylesheet->card_width, set->stylesheet->card_height) + ws - cs;
} else {
return cs;
}
}
void CardViewer::onPaint(wxPaintEvent&) {
+1 -1
View File
@@ -17,7 +17,7 @@
/// A control to view a single card
class CardViewer : public wxControl, public DataViewer {
public:
CardViewer(Window* parent, int id, int style);
CardViewer(Window* parent, int id, long style = 0);
protected:
/// Return the desired size of control
+6 -3
View File
@@ -8,6 +8,7 @@
#include <gui/set/cards_panel.hpp>
#include <gui/control/card_list.hpp>
#include <gui/control/card_editor.hpp>
#include <gui/icon_menu.hpp>
#include <data/set.hpp>
#include <data/action/set.hpp>
@@ -21,8 +22,9 @@ CardsPanel::CardsPanel(Window* parent, int id)
: SetWindowPanel(parent, id, false)
{
// init controls
// Panel* notesP
editor = new CardEditor(this, ID_EDITOR);
// splitter = new SplitterWindow(&this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0);
// card_list = new EditCardList(splitter, idCardList);
// card_list = new EditCardList(splitter, ID_CARD_LIST);
card_list = new CardListBase(this, ID_CARD_LIST);
// init splitter
@@ -37,6 +39,7 @@ CardsPanel::CardsPanel(Window* parent, int id)
SetSizer(s);
*/
wxSizer* s = new wxBoxSizer(wxHORIZONTAL);
s->Add(editor, 0, wxRIGHT, 2);
s->Add(card_list, 1, wxEXPAND);
SetSizer(s);
}
@@ -46,7 +49,7 @@ CardsPanel::~CardsPanel() {
}
void CardsPanel::onChangeSet() {
// editor->setSet(set);
editor->setSet(set);
card_list->setSet(set);
/* // resize editor
Sizer* s = sizer;
@@ -207,5 +210,5 @@ CardP CardsPanel::selectedCard() const {
}
void CardsPanel::selectCard(const CardP& card) {
card_list->setCard(card);
// editor->setCard(card);
editor->setCard(*card);
}
+4 -3
View File
@@ -14,6 +14,7 @@
class wxSplitterWindow;
class CardListBase;
class DataEditor;
// ----------------------------------------------------------------------------- : CardsPanel
@@ -92,9 +93,9 @@ class CardsPanel : public SetWindowPanel {
private:
// --------------------------------------------------- : Controls
wxSplitterWindow* splitter;
// Editor* editor;
CardListBase* card_list;
// DataTextCtrl* notes;
DataEditor* editor;
CardListBase* card_list;
// DataTextCtrl* notes;
// --------------------------------------------------- : Menus & tools
wxMenu* cardMenu, formatMenu;
+9 -2
View File
@@ -12,6 +12,7 @@
#include <gui/set/set_info_panel.hpp>
#include <gui/set/style_panel.hpp>
#include <gui/set/stats_panel.hpp>
#include <gui/control/card_list.hpp>
#include <gui/about_window.hpp>
#include <gui/new_window.hpp>
#include <gui/icon_menu.hpp>
@@ -540,12 +541,18 @@ void SetWindow::onHelpAbout(wxCommandEvent&) {
wnd.ShowModal();
}
// ----------------------------------------------------------------------------- : Window events - menu - for child panel
// ----------------------------------------------------------------------------- : Window events - other
void SetWindow::onChildMenu(wxCommandEvent& ev) {
current_panel->onCommand(ev.GetId());
}
void SetWindow::onCardSelect(CardSelectEvent& ev) {
FOR_EACH(p, panels) {
p->selectCard(ev.card);
}
}
// ----------------------------------------------------------------------------- : Event table
BEGIN_EVENT_TABLE(SetWindow, wxFrame)
@@ -586,5 +593,5 @@ BEGIN_EVENT_TABLE(SetWindow, wxFrame)
EVT_CLOSE ( SetWindow::onClose)
// EVT_TIMER (wxID_ANY, SetWindow::onTick)
// EVT_IDLE ( SetWindow::onIdle)
// EVT_CARD_SELECT (wxID_ANY, SetWindow::onCardSelect)
EVT_CARD_SELECT (wxID_ANY, SetWindow::onCardSelect)
END_EVENT_TABLE ()
+4 -1
View File
@@ -16,6 +16,7 @@
class IconMenu;
class SetWindowPanel;
class wxFindDialogEvent;
struct CardSelectEvent;
// ----------------------------------------------------------------------------- : SetWindow
@@ -150,9 +151,11 @@ class SetWindow : public wxFrame, public SetView {
void onHelpIndex (wxCommandEvent&);
void onHelpAbout (wxCommandEvent&);
// --------------------------------------------------- : Window events - menu - for child panel
// --------------------------------------------------- : Window events - other
void onChildMenu (wxCommandEvent&);
void onCardSelect (CardSelectEvent&);
};
// ----------------------------------------------------------------------------- : EOF