Added support for informational headings in native look editor.

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@212 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2007-03-18 14:50:44 +00:00
parent 074ff12816
commit d30e0f7bc5
14 changed files with 395 additions and 15 deletions
+21 -14
View File
@@ -30,18 +30,21 @@ void NativeLookEditor::draw(DC& dc) {
}
void NativeLookEditor::drawViewer(RotatedDC& dc, ValueViewer& v) {
if (!shouldDraw(v)) return;
// 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);
// TODO : tr using stylesheet or using game?
dc.DrawText(tr(*set->game, s.fieldP->name, capitalize_sentence(s.fieldP->name)),
RealPoint(margin_left, s.top + 1));
// draw 3D border
draw_control_border(this, dc.getDC(), RealRect(s.left - 1, s.top - 1, s.width + 2, s.height + 2));
ValueEditor* e = v.getEditor();
if (!e || e->drawLabel()) {
// 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);
// TODO : tr using stylesheet or using game?
dc.DrawText(tr(*set->game, s.fieldP->name, capitalize_sentence(s.fieldP->name)),
RealPoint(margin_left, s.top + 1));
// draw 3D border
draw_control_border(this, dc.getDC(), RealRect(s.left - 1, s.top - 1, s.width + 2, s.height + 2));
}
// draw viewer
v.draw(dc);
}
@@ -55,11 +58,15 @@ void NativeLookEditor::resizeViewers() {
// Set editor sizes
FOR_EACH(v, viewers) {
StyleP s = v->getStyle();
s->left = margin + label_width;
ValueEditor* e = v->getEditor();
if (!e || e->drawLabel()) {
s->left = margin + label_width;
} else {
s->left = margin;
}
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;
}
+2
View File
@@ -13,6 +13,7 @@
#include <gui/value/image.hpp>
#include <gui/value/symbol.hpp>
#include <gui/value/color.hpp>
#include <gui/value/information.hpp>
// ----------------------------------------------------------------------------- : ValueEditor
@@ -30,3 +31,4 @@ IMPLEMENT_MAKE_EDITOR(MultipleChoice);
IMPLEMENT_MAKE_EDITOR(Color);
IMPLEMENT_MAKE_EDITOR(Image);
IMPLEMENT_MAKE_EDITOR(Symbol);
IMPLEMENT_MAKE_EDITOR(Info);
+3 -1
View File
@@ -98,8 +98,10 @@ class ValueEditor {
/// The cursor type to use when the mouse is over this control
virtual wxCursor cursor() const { return wxCursor(); }
/// determines prefered size in the native look, update the style
/// Determines prefered size in the native look, update the style
virtual void determineSize(bool force_fit = false) {}
/// Should a label and control border be drawn in the native look?
virtual bool drawLabel() const { return true; }
/// The editor is shown or hidden
virtual void onShow(bool) {}
+17
View File
@@ -0,0 +1,17 @@
//+----------------------------------------------------------------------------+
//| 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/value/information.hpp>
// ----------------------------------------------------------------------------- : InfoValueEditor
IMPLEMENT_VALUE_EDITOR(Info) {}
void InfoValueEditor::determineSize(bool) {
style().height = 26;
}
+28
View File
@@ -0,0 +1,28 @@
//+----------------------------------------------------------------------------+
//| 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_VALUE_INFORMATION
#define HEADER_GUI_VALUE_INFORMATION
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <gui/value/editor.hpp>
#include <render/value/information.hpp>
// ----------------------------------------------------------------------------- : InfoValueEditor
/// An editor 'control' for editing InfoValues
class InfoValueEditor : public InfoValueViewer, public ValueEditor {
public:
DECLARE_VALUE_EDITOR(Info);
virtual void determineSize(bool);
virtual bool drawLabel() const { return false; }
};
// ----------------------------------------------------------------------------- : EOF
#endif