mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -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:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user