mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 21:06:59 -04:00
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:
@@ -18,13 +18,6 @@ DECLARE_TYPEOF_COLLECTION(ValueViewer*);
|
||||
|
||||
// ----------------------------------------------------------------------------- : DataEditor
|
||||
|
||||
#define FOR_EACH_EDITOR \
|
||||
FOR_EACH(v, viewers) \
|
||||
if (ValueEditor* e = v->getEditor())
|
||||
#define FOR_EACH_EDITOR_REVERSE \
|
||||
FOR_EACH_REVERSE(v, viewers) \
|
||||
if (ValueEditor* e = v->getEditor())
|
||||
|
||||
DataEditor::DataEditor(Window* parent, int id, long style)
|
||||
: CardViewer(parent, id, style)
|
||||
, current_viewer(nullptr)
|
||||
|
||||
@@ -110,5 +110,14 @@ class DataEditor : public CardViewer {
|
||||
/// By default a DataEditor edits cards
|
||||
typedef DataEditor CardEditor;
|
||||
|
||||
// ----------------------------------------------------------------------------- : Utility
|
||||
|
||||
#define FOR_EACH_EDITOR \
|
||||
FOR_EACH(v, viewers) \
|
||||
if (ValueEditor* e = v->getEditor())
|
||||
#define FOR_EACH_EDITOR_REVERSE \
|
||||
FOR_EACH_REVERSE(v, viewers) \
|
||||
if (ValueEditor* e = v->getEditor())
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
#endif
|
||||
|
||||
@@ -29,7 +29,7 @@ DEFINE_EVENT_TYPE(EVENT_CARD_SELECT);
|
||||
|
||||
// ----------------------------------------------------------------------------- : CardListBase
|
||||
|
||||
CardListBase::CardListBase(Window* parent, int id, int additional_style)
|
||||
CardListBase::CardListBase(Window* parent, int id, long additional_style)
|
||||
: wxListView(parent, id, wxDefaultPosition, wxDefaultSize, additional_style | wxLC_REPORT | wxLC_VIRTUAL | wxLC_SINGLE_SEL)
|
||||
{
|
||||
// create image list
|
||||
|
||||
@@ -47,7 +47,7 @@ struct CardSelectEvent : public wxCommandEvent {
|
||||
*/
|
||||
class CardListBase : public wxListView, public SetView {
|
||||
public:
|
||||
CardListBase(Window* parent, int id, int additional_style = 0);
|
||||
CardListBase(Window* parent, int id, long additional_style = 0);
|
||||
~CardListBase();
|
||||
|
||||
// --------------------------------------------------- : Selection
|
||||
|
||||
@@ -12,7 +12,7 @@ DECLARE_TYPEOF_COLLECTION(CardP);
|
||||
|
||||
// ----------------------------------------------------------------------------- : FilteredCardList
|
||||
|
||||
FilteredCardList::FilteredCardList(Window* parent, int id, int style)
|
||||
FilteredCardList::FilteredCardList(Window* parent, int id, long style)
|
||||
: CardListBase(parent, id, style)
|
||||
{}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ class CardListFilter {
|
||||
/// A card list that lists a subset of the cards in the set
|
||||
class FilteredCardList : public CardListBase {
|
||||
public:
|
||||
FilteredCardList(Window* parent, int id, int style = 0);
|
||||
FilteredCardList(Window* parent, int id, long style = 0);
|
||||
|
||||
/// Change the filter to use
|
||||
void setFilter(const CardListFilterP& filter_);
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| 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/native_look_editor.hpp>
|
||||
#include <gui/value/editor.hpp>
|
||||
#include <gui/util.hpp>
|
||||
#include <data/stylesheet.hpp>
|
||||
|
||||
DECLARE_TYPEOF_COLLECTION(ValueViewerP);
|
||||
typedef IndexMap<FieldP,StyleP> IndexMap_FieldP_StyleP;
|
||||
DECLARE_TYPEOF_NO_REV(IndexMap_FieldP_StyleP);
|
||||
|
||||
// ----------------------------------------------------------------------------- : NativeLookEditor
|
||||
|
||||
NativeLookEditor::NativeLookEditor(Window* parent, int id, long style)
|
||||
: DataEditor(parent, id, style)
|
||||
{}
|
||||
|
||||
void NativeLookEditor::draw(DC& dc) {
|
||||
RotatedDC rdc(dc, 0, RealRect(RealPoint(0,0),GetClientSize()), 1, 0);
|
||||
DataViewer::draw(rdc, wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
|
||||
}
|
||||
void NativeLookEditor::drawViewer(RotatedDC& dc, ValueViewer& v) {
|
||||
// draw background
|
||||
Style& s = *v.getStyle();
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
dc.DrawRectangle(s.getRect().grow(1));
|
||||
// draw label
|
||||
dc.SetFont(*wxNORMAL_FONT);
|
||||
dc.DrawText(capitalize_sentence(s.fieldP->name), RealPoint(margin_left, s.top + 1));
|
||||
// draw 3D border
|
||||
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() {
|
||||
// size stuff
|
||||
UInt y = margin;
|
||||
int w;
|
||||
GetClientSize(&w, 0);
|
||||
const int default_height = 17;
|
||||
// Set editor sizes
|
||||
FOR_EACH(v, viewers) {
|
||||
StyleP s = v->getStyle();
|
||||
s->left = margin + label_width;
|
||||
s->top = y;
|
||||
s->width = w - s->left - margin;
|
||||
s->height = default_height;
|
||||
ValueEditor* e = v->getEditor();
|
||||
if (e) e->determineSize();
|
||||
y += s->height + vspace;
|
||||
}
|
||||
}
|
||||
|
||||
void NativeLookEditor::onInit() {
|
||||
// Give fieldEditors a chance to show/hide controls (scrollbar) when selecting other editors
|
||||
FOR_EACH_EDITOR {
|
||||
e->onShow(true);
|
||||
}
|
||||
resizeViewers();
|
||||
}
|
||||
|
||||
wxSize NativeLookEditor::DoGetBestSize() const {
|
||||
return wxSize(200, 200);
|
||||
}
|
||||
void NativeLookEditor::onSize(wxSizeEvent& ev) {
|
||||
// CardViewre::onSize(ev);
|
||||
resizeViewers();
|
||||
}
|
||||
|
||||
BEGIN_EVENT_TABLE(NativeLookEditor, DataEditor)
|
||||
EVT_SIZE (NativeLookEditor::onSize)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------- : SetInfoEditor
|
||||
|
||||
SetInfoEditor::SetInfoEditor(Window* parent, int id, long style)
|
||||
: NativeLookEditor(parent, id, style)
|
||||
{}
|
||||
|
||||
void SetInfoEditor::onChangeSet() {
|
||||
setStyles(set->stylesheet->set_info_style);
|
||||
setData(set->data);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : StylingEditor
|
||||
|
||||
StylingEditor::StylingEditor(Window* parent, int id, long style)
|
||||
: NativeLookEditor(parent, id, style)
|
||||
{}
|
||||
|
||||
void StylingEditor::showStylesheet(const StyleSheetP& stylesheet) {
|
||||
this->stylesheet = stylesheet;
|
||||
setStyles(stylesheet->styling_style);
|
||||
setData(set->stylingDataFor(*stylesheet));
|
||||
}
|
||||
|
||||
void StylingEditor::onChangeSet() {
|
||||
showStylesheet(set->stylesheet);
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| 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_NATIVE_LOOK_EDITOR
|
||||
#define HEADER_GUI_CONTROL_NATIVE_LOOK_EDITOR
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <gui/control/card_editor.hpp>
|
||||
|
||||
// ----------------------------------------------------------------------------- : NativeLookEditor
|
||||
|
||||
/// A data editor with a platform native look
|
||||
class NativeLookEditor : public DataEditor {
|
||||
public:
|
||||
NativeLookEditor(Window* parent, int id, long style = 0);
|
||||
|
||||
/// Uses a native look
|
||||
virtual bool nativeLook() const { return true; }
|
||||
virtual bool drawBorders() const { return false; }
|
||||
|
||||
virtual void draw(DC& dc);
|
||||
virtual void drawViewer(RotatedDC& dc, ValueViewer& v);
|
||||
|
||||
protected:
|
||||
// Best size doesn't really matter, as long as it is not too small
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
virtual void onInit();
|
||||
|
||||
private:
|
||||
static const UInt margin = 6;
|
||||
static const UInt margin_left = 4;
|
||||
static const UInt label_width = 150;
|
||||
static const UInt vspace = 10;
|
||||
|
||||
DECLARE_EVENT_TABLE();
|
||||
|
||||
void onSize(wxSizeEvent&);
|
||||
/// Resize the viewers so they match with this control
|
||||
void resizeViewers();
|
||||
};
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------- : SetInfoEditor
|
||||
|
||||
/// Editor for set.data
|
||||
class SetInfoEditor : public NativeLookEditor {
|
||||
public:
|
||||
SetInfoEditor(Window* parent, int id, long style = 0);
|
||||
protected:
|
||||
virtual void onChangeSet();
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : StylingEditor
|
||||
|
||||
/// Editor for styling data
|
||||
class StylingEditor : public NativeLookEditor {
|
||||
public:
|
||||
StylingEditor(Window* parent, int id, long style = 0);
|
||||
|
||||
/// Show the styling for given stylesheet in the editor
|
||||
void showStylesheet(const StyleSheetP& stylesheet);
|
||||
|
||||
protected:
|
||||
virtual void onChangeSet();
|
||||
|
||||
private:
|
||||
StyleSheetP stylesheet; ///< The stylesheet for which we are showing the styling data
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
#endif
|
||||
Reference in New Issue
Block a user