mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
added TextCtrl control for things like card.notes and keyword stuff
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@112 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -42,8 +42,6 @@ void NativeLookEditor::drawViewer(RotatedDC& dc, ValueViewer& v) {
|
||||
draw_control_border(this, dc.getDC(), wxRect(s.left - 1, s.top - 1, s.width + 2, s.height + 2));
|
||||
// draw viewer
|
||||
v.draw(dc);
|
||||
ValueEditor* e = v.getEditor();
|
||||
if (e) e->drawSelection(dc);
|
||||
}
|
||||
|
||||
void NativeLookEditor::resizeViewers() {
|
||||
@@ -66,7 +64,7 @@ void NativeLookEditor::resizeViewers() {
|
||||
}
|
||||
|
||||
void NativeLookEditor::onInit() {
|
||||
// Give fieldEditors a chance to show/hide controls (scrollbar) when selecting other editors
|
||||
// Give viewers a chance to show/hide controls (scrollbar) when selecting other editors
|
||||
FOR_EACH_EDITOR {
|
||||
e->onShow(true);
|
||||
}
|
||||
|
||||
+21
-15
@@ -9,9 +9,11 @@
|
||||
#include <gui/set/cards_panel.hpp>
|
||||
#include <gui/control/card_list.hpp>
|
||||
#include <gui/control/card_editor.hpp>
|
||||
#include <gui/control/text_ctrl.hpp>
|
||||
#include <gui/icon_menu.hpp>
|
||||
#include <gui/util.hpp>
|
||||
#include <data/set.hpp>
|
||||
#include <data/card.hpp>
|
||||
#include <data/action/set.hpp>
|
||||
#include <data/settings.hpp>
|
||||
#include <util/window_id.hpp>
|
||||
@@ -23,25 +25,27 @@ 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);
|
||||
wxPanel* notesP;
|
||||
wxSplitterWindow* splitter;
|
||||
editor = new CardEditor(this, ID_EDITOR);
|
||||
splitter = new wxSplitterWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0);
|
||||
// card_list = new EditCardList(splitter, ID_CARD_LIST);
|
||||
card_list = new CardListBase(this, ID_CARD_LIST);
|
||||
card_list = new CardListBase(splitter, ID_CARD_LIST);
|
||||
notesP = new Panel(splitter, wxID_ANY);
|
||||
notes = new TextCtrl(notesP, ID_NOTES);
|
||||
// init sizer for notes panel
|
||||
wxSizer* sn = new wxBoxSizer(wxVERTICAL);
|
||||
sn->Add(new wxStaticText(notesP, wxID_ANY, _("Card notes:")), 0, wxEXPAND, 2);
|
||||
sn->Add(notes, 1, wxEXPAND | wxTOP, 2);
|
||||
notesP->SetSizer(sn);
|
||||
// init splitter
|
||||
// splitter->minimumPaneSize = 14;
|
||||
// splitter->sashGravity = 1.0;
|
||||
// splitter->splitHorizontally(cardList, notesP, -40);
|
||||
splitter->SetMinimumPaneSize(14);
|
||||
splitter->SetSashGravity(1.0);
|
||||
splitter->SplitHorizontally(card_list, notesP, -40);
|
||||
// init sizer
|
||||
/* Sizer* s = new wxBoxSizer(wxHORIZONTAL);
|
||||
s->Add(editor, 0, wxRIGHT, 2);
|
||||
s->Add(splitter, 1, wxEXPAND);
|
||||
s->SetSizeHints(this);
|
||||
SetSizer(s);
|
||||
*/
|
||||
wxSizer* s = new wxBoxSizer(wxHORIZONTAL);
|
||||
s->Add(editor, 0, wxRIGHT, 2);
|
||||
s->Add(card_list, 1, wxEXPAND);
|
||||
s->Add(editor, 0, wxRIGHT, 2);
|
||||
s->Add(splitter, 1, wxEXPAND);
|
||||
s->SetSizeHints(this);
|
||||
SetSizer(s);
|
||||
}
|
||||
@@ -52,6 +56,7 @@ CardsPanel::~CardsPanel() {
|
||||
|
||||
void CardsPanel::onChangeSet() {
|
||||
editor->setSet(set);
|
||||
notes->setSet(set);
|
||||
card_list->setSet(set);
|
||||
/* // resize editor
|
||||
Sizer* s = sizer;
|
||||
@@ -230,4 +235,5 @@ CardP CardsPanel::selectedCard() const {
|
||||
void CardsPanel::selectCard(const CardP& card) {
|
||||
card_list->setCard(card);
|
||||
editor->setCard(card);
|
||||
notes->setValue(card ? &card->notes : nullptr);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
class wxSplitterWindow;
|
||||
class CardListBase;
|
||||
class DataEditor;
|
||||
class TextCtrl;
|
||||
|
||||
// ----------------------------------------------------------------------------- : CardsPanel
|
||||
|
||||
@@ -83,7 +84,7 @@ class CardsPanel : public SetWindowPanel {
|
||||
bool findInValue(const CardP& crd_, virtual const ValueP& value, int firstChar, FindReplaceData& what, const FindHandler& handler);
|
||||
*/
|
||||
public:
|
||||
|
||||
|
||||
// --------------------------------------------------- : Selection
|
||||
virtual CardP selectedCard() const;
|
||||
virtual void selectCard(const CardP& card);
|
||||
@@ -93,7 +94,7 @@ class CardsPanel : public SetWindowPanel {
|
||||
wxSplitterWindow* splitter;
|
||||
DataEditor* editor;
|
||||
CardListBase* card_list;
|
||||
// DataTextCtrl* notes;
|
||||
TextCtrl* notes;
|
||||
|
||||
// --------------------------------------------------- : Menus & tools
|
||||
wxMenu* cardMenu, formatMenu;
|
||||
|
||||
@@ -7,9 +7,25 @@
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <gui/set/keywords_panel.hpp>
|
||||
#include <data/keyword.hpp>
|
||||
#include <wx/listctrl.h>
|
||||
|
||||
// ----------------------------------------------------------------------------- : KeywordsList
|
||||
|
||||
/// A control that lists the keywords in a set or game
|
||||
class KeywordList : public wxListView {
|
||||
public:
|
||||
KeywordList(Window* parent, int id);
|
||||
|
||||
/// Set the list of keywords to show
|
||||
void setData(vector<KeywordP>& dat);
|
||||
|
||||
bool canSelectPrevious() const;
|
||||
bool canSelectNext() const;
|
||||
void selectPrevious();
|
||||
void selectNext();
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : KeywordsPanel
|
||||
|
||||
KeywordsPanel::KeywordsPanel(Window* parent, int id)
|
||||
|
||||
@@ -102,7 +102,8 @@ void ChoiceValueEditor::onLoseFocus() {
|
||||
drop_down->hide(false);
|
||||
}
|
||||
|
||||
void ChoiceValueEditor::drawSelection(RotatedDC& dc) {
|
||||
void ChoiceValueEditor::draw(RotatedDC& dc) {
|
||||
ChoiceValueViewer::draw(dc);
|
||||
if (nativeLook()) {
|
||||
draw_drop_down_arrow(&editor(), dc.getDC(), style().getRect().grow(1), drop_down->IsShown());
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ class ChoiceValueEditor : public ChoiceValueViewer, public ValueEditor {
|
||||
virtual void onChar(wxKeyEvent& ev);
|
||||
virtual void onLoseFocus();
|
||||
|
||||
virtual void drawSelection(RotatedDC& dc);
|
||||
virtual void draw(RotatedDC& dc);
|
||||
virtual void determineSize();
|
||||
|
||||
private:
|
||||
|
||||
@@ -138,7 +138,8 @@ void ColorValueEditor::onLoseFocus() {
|
||||
drop_down->hide(false);
|
||||
}
|
||||
|
||||
void ColorValueEditor::drawSelection(RotatedDC& dc) {
|
||||
void ColorValueEditor::draw(RotatedDC& dc) {
|
||||
ColorValueViewer::draw(dc);
|
||||
if (nativeLook()) {
|
||||
draw_drop_down_arrow(&editor(), dc.getDC(), style().getRect().grow(1), drop_down->IsShown());
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ class ColorValueEditor : public ColorValueViewer, public ValueEditor {
|
||||
virtual void onChar(wxKeyEvent& ev);
|
||||
virtual void onLoseFocus();
|
||||
|
||||
virtual void drawSelection(RotatedDC& dc);
|
||||
virtual void draw(RotatedDC& dc);
|
||||
virtual void determineSize();
|
||||
|
||||
private:
|
||||
|
||||
@@ -99,11 +99,6 @@ class ValueEditor {
|
||||
virtual void determineSize() {}
|
||||
/// The editor is shown or hidden
|
||||
virtual void onShow(bool) {}
|
||||
|
||||
/// Draw selection indicators
|
||||
/** note: the drawing of the value is done by the viewer, only a selection indicator is drawn here
|
||||
*/
|
||||
virtual void drawSelection(RotatedDC& dc) {}
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : Utility
|
||||
|
||||
@@ -585,6 +585,12 @@
|
||||
<File
|
||||
RelativePath=".\gui\control\package_list.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gui\control\text_ctrl.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gui\control\text_ctrl.hpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="symbol"
|
||||
|
||||
@@ -53,6 +53,12 @@ class IndexMap : private vector<Value> {
|
||||
init_object(key, (*this)[key->index]);
|
||||
}
|
||||
}
|
||||
/// Change this map by adding an additional key and value
|
||||
void add(const Key& key, const Value& value) {
|
||||
assert(get_key(value) == key);
|
||||
if (key->index >= this->size()) this->resize(key->index + 1);
|
||||
(*this)[key->index] = value;
|
||||
}
|
||||
|
||||
/// Retrieve a value given its key
|
||||
inline Value operator [] (const Key& key) {
|
||||
|
||||
Reference in New Issue
Block a user