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:
@@ -31,6 +31,14 @@ IMPLEMENT_REFLECTION(BooleanField) {
|
||||
|
||||
// ----------------------------------------------------------------------------- : BooleanStyle
|
||||
|
||||
BooleanStyle::BooleanStyle(const ChoiceFieldP& field)
|
||||
: ChoiceStyle(field)
|
||||
{
|
||||
render_style = RENDER_BOTH;
|
||||
choice_images[_("yes")] = ScriptableImage(_("buildin_image(\"bool_yes\")"));
|
||||
choice_images[_("no")] = ScriptableImage(_("buildin_image(\"bool_no\")"));
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION(BooleanStyle) {
|
||||
REFLECT_BASE(ChoiceStyle);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class BooleanField : public ChoiceField {
|
||||
/// The Style for a BooleanField
|
||||
class BooleanStyle : public ChoiceStyle {
|
||||
public:
|
||||
inline BooleanStyle(const ChoiceFieldP& field) : ChoiceStyle(field) {}
|
||||
BooleanStyle(const ChoiceFieldP& field);
|
||||
DECLARE_HAS_FIELD(Boolean); // not DECLARE_STYLE_TYPE, because we use a normal ChoiceValueViewer/Editor
|
||||
|
||||
// no extra data
|
||||
|
||||
@@ -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
|
||||
@@ -25,7 +25,7 @@ class CardsPanel : public SetWindowPanel {
|
||||
~CardsPanel();
|
||||
|
||||
void onChangeSet();
|
||||
|
||||
|
||||
// --------------------------------------------------- : UI
|
||||
|
||||
virtual void initUI (wxToolBar* tb, wxMenuBar* mb);
|
||||
|
||||
@@ -7,10 +7,77 @@
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <gui/set/set_info_panel.hpp>
|
||||
#include <gui/control/native_look_editor.hpp>
|
||||
#include <gui/icon_menu.hpp>
|
||||
#include <util/window_id.hpp>
|
||||
|
||||
// ----------------------------------------------------------------------------- : SetInfoPanel
|
||||
|
||||
SetInfoPanel::SetInfoPanel(Window* parent, int id)
|
||||
: SetWindowPanel(parent, id)
|
||||
{
|
||||
// init controls
|
||||
editor = new SetInfoEditor(this, wxID_ANY);
|
||||
// init sizer
|
||||
wxSizer* s = new wxBoxSizer(wxVERTICAL);
|
||||
s->Add(editor, 1, wxEXPAND, 2);
|
||||
s->SetSizeHints(this);
|
||||
SetSizer(s);
|
||||
}
|
||||
|
||||
void SetInfoPanel::onChangeSet() {
|
||||
editor->setSet(set);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : UI
|
||||
|
||||
void SetInfoPanel::initUI(wxToolBar* tb, wxMenuBar* mb) {
|
||||
// Toolbar
|
||||
tb->AddTool(ID_FORMAT_BOLD, _(""), Bitmap(_("TOOL_BOLD")), wxNullBitmap, wxITEM_CHECK, _("Bold"));
|
||||
tb->AddTool(ID_FORMAT_ITALIC, _(""), Bitmap(_("TOOL_ITALIC")), wxNullBitmap, wxITEM_CHECK, _("Italic"));
|
||||
tb->AddTool(ID_FORMAT_SYMBOL, _(""), Bitmap(_("TOOL_SYMBOL")), wxNullBitmap, wxITEM_CHECK, _("Symbols"));
|
||||
tb->Realize();
|
||||
// Menus
|
||||
IconMenu* menuFormat = new IconMenu();
|
||||
menuFormat->Append(ID_FORMAT_BOLD, _("TOOL_BOLD"), _("Bold\tCtrl+B"), _("Makes the selected text bold"), wxITEM_CHECK);
|
||||
menuFormat->Append(ID_FORMAT_ITALIC, _("TOOL_ITALIC"), _("Italic\tCtrl+I"), _("Makes the selected text italic"), wxITEM_CHECK);
|
||||
menuFormat->Append(ID_FORMAT_SYMBOL, _("TOOL_SYMBOL"), _("Symbols\tCtrl+M"), _("Draws the selected text with symbols"), wxITEM_CHECK);
|
||||
menuFormat->Append(ID_FORMAT_REMINDER, _("TOOL_REMINDER"), _("Reminder Text\tCtrl+R"), _("Show reminder text for the selected keyword"), wxITEM_CHECK);
|
||||
mb->Insert(2, menuFormat, _("&Format"));
|
||||
}
|
||||
|
||||
void SetInfoPanel::destroyUI(wxToolBar* tb, wxMenuBar* mb) {
|
||||
// Toolbar
|
||||
tb->DeleteTool(ID_FORMAT_BOLD);
|
||||
tb->DeleteTool(ID_FORMAT_ITALIC);
|
||||
tb->DeleteTool(ID_FORMAT_SYMBOL);
|
||||
// Menus
|
||||
delete mb->Remove(2);
|
||||
}
|
||||
|
||||
void SetInfoPanel::onUpdateUI(wxUpdateUIEvent& e) {
|
||||
switch (e.GetId()) {
|
||||
case ID_FORMAT_BOLD: case ID_FORMAT_ITALIC: case ID_FORMAT_SYMBOL: {
|
||||
e.Enable(editor->canFormat(e.GetId()));
|
||||
e.Check (editor->hasFormat(e.GetId()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SetInfoPanel::onCommand(int id) {
|
||||
switch (id) {
|
||||
case ID_FORMAT_BOLD: case ID_FORMAT_ITALIC: case ID_FORMAT_SYMBOL: {
|
||||
editor->doFormat(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Clipboard
|
||||
|
||||
bool SetInfoPanel::canCut() const { return editor->canCut(); }
|
||||
bool SetInfoPanel::canCopy() const { return editor->canCopy(); }
|
||||
bool SetInfoPanel::canPaste() const { return editor->canPaste(); }
|
||||
void SetInfoPanel::doCut() { editor->doCut(); }
|
||||
void SetInfoPanel::doCopy() { editor->doCopy(); }
|
||||
void SetInfoPanel::doPaste() { editor->doPaste(); }
|
||||
|
||||
@@ -12,11 +12,35 @@
|
||||
#include <util/prec.hpp>
|
||||
#include <gui/set/panel.hpp>
|
||||
|
||||
class SetInfoEditor;
|
||||
|
||||
// ----------------------------------------------------------------------------- : SetInfoPanel
|
||||
|
||||
class SetInfoPanel : public SetWindowPanel {
|
||||
public:
|
||||
SetInfoPanel(Window* parent, int id);
|
||||
|
||||
// --------------------------------------------------- : UI
|
||||
|
||||
virtual void initUI (wxToolBar* tb, wxMenuBar* mb);
|
||||
virtual void destroyUI(wxToolBar* tb, wxMenuBar* mb);
|
||||
virtual void onUpdateUI(wxUpdateUIEvent& e);
|
||||
virtual void onCommand(int id);
|
||||
|
||||
// --------------------------------------------------- : Clipboard
|
||||
|
||||
virtual bool canCut() const;
|
||||
virtual bool canCopy() const;
|
||||
virtual bool canPaste() const;
|
||||
virtual void doCut();
|
||||
virtual void doCopy();
|
||||
virtual void doPaste();
|
||||
|
||||
protected:
|
||||
virtual void onChangeSet();
|
||||
|
||||
private:
|
||||
SetInfoEditor* editor;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
|
||||
+6
-11
@@ -116,16 +116,13 @@ SetWindow::SetWindow(Window* parent, const SetP& set)
|
||||
// NOTE: place the CardsPanel last in the panels list,
|
||||
// this way the card list is the last to be told of a set change
|
||||
// this way everyone else already uses the new set when it sends a CardSelectEvent
|
||||
addPanel(menuWindow, tabBar, new CardsPanel (this, wxID_ANY), 2, _("F5"), _("Cards"), _("Cards"), _("Edit the cards in the set"));
|
||||
// addPanel(menuWindow, tabBar, new SetInfoPanel (this, wxID_ANY), 0, _("F6"));
|
||||
addPanel(menuWindow, tabBar, new StylePanel (this, wxID_ANY), 1, _("F7"), _("Style"), _("Style"), _("Change the style of cards"));
|
||||
addPanel(menuWindow, tabBar, new CardsPanel (this, wxID_ANY), 3, _("F5"), _("Cards"), _("Cards"), _("Edit the cards in the set"));
|
||||
addPanel(menuWindow, tabBar, new SetInfoPanel (this, wxID_ANY), 0, _("F6"), _("Set info"), _("&Set Information"), _("Edit information about the set, its creator, etc."));
|
||||
addPanel(menuWindow, tabBar, new StylePanel (this, wxID_ANY), 1, _("F7"), _("Style"), _("Style"), _("Change the style of cards"));
|
||||
// addPanel(menuWindow, tabBar, new KeywordsPanel(this, wxID_ANY), 2, _("F8"));
|
||||
// addPanel(menuWindow, tabBar, new StatsPanel (this, wxID_ANY), 3, _("F9"), _("Stats"), _("Statistics"), _("Show statistics about the cards in the set"));
|
||||
//addPanel(*s, *menuWindow, *tabBar, new DraftPanel (&this, wxID_ANY), 4, _("F10"))
|
||||
// selectPanel(idWindowMin + 4); // select cards panel
|
||||
|
||||
addPanel(menuWindow, tabBar, new StatsPanel (this, wxID_ANY), 0, _("F9"), _("Stats"), _("Statistics"), _("Show statistics about the cards in the set"));
|
||||
selectPanel(ID_WINDOW_MIN+2); // test
|
||||
addPanel(menuWindow, tabBar, new StatsPanel (this, wxID_ANY), 2, _("F9"), _("Stats"), _("Statistics"), _("Show statistics about the cards in the set"));
|
||||
// addPanel(*s, *menuWindow, *tabBar, new DraftPanel (&this, wxID_ANY), 4, _("F10"))
|
||||
selectPanel(ID_WINDOW_MIN + 3); // select cards panel
|
||||
|
||||
// loose ends
|
||||
tabBar->Realize();
|
||||
@@ -227,8 +224,6 @@ void SetWindow::onChangeSet() {
|
||||
// make sure there is always at least one card
|
||||
// some things need this
|
||||
if (set->cards.empty()) set->cards.push_back(new_shared1<Card>(*set->game));
|
||||
// does the set need a scriptUpdater? If so, we can do it
|
||||
// if (!set->scriptUpdater) scriptUpdater.set = set;
|
||||
// all panels view the same set
|
||||
FOR_EACH(p, panels) {
|
||||
p->setSet(set);
|
||||
|
||||
+58
-2
@@ -11,6 +11,12 @@
|
||||
#include <util/rotation.hpp>
|
||||
#include <wx/mstream.h>
|
||||
|
||||
#if defined(wxMSW) && wxUSE_UXTHEME
|
||||
#include <wx/msw/uxtheme.h>
|
||||
#include <tmschema.h>
|
||||
#include <shlobj.h>
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------- : DC related
|
||||
|
||||
/// Fill a DC with a single color
|
||||
@@ -43,7 +49,7 @@ void draw_checker(RotatedDC& dc, const RealRect& rect) {
|
||||
|
||||
// ----------------------------------------------------------------------------- : Image related
|
||||
|
||||
Image load_resource_image(String name) {
|
||||
Image load_resource_image(const String& name) {
|
||||
#ifdef __WXMSW__
|
||||
// Load resource
|
||||
// based on wxLoadUserResource
|
||||
@@ -61,4 +67,54 @@ Image load_resource_image(String name) {
|
||||
wxMemoryInputStream stream(data, len);
|
||||
return wxImage(stream);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Platform look
|
||||
|
||||
// Draw a basic 3D border
|
||||
void draw3DBorder(DC& dc, int x1, int y1, int x2, int y2) {
|
||||
dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DDKSHADOW));
|
||||
dc.DrawLine(x1, y1, x2, y1);
|
||||
dc.DrawLine(x1, y1, x1, y2);
|
||||
dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW));
|
||||
dc.DrawLine(x1-1, y1-1, x2+1, y1-1);
|
||||
dc.DrawLine(x1-1, y1-1, x1-1, y2+1);
|
||||
dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT));
|
||||
dc.DrawLine(x1, y2, x2, y2);
|
||||
dc.DrawLine(x2, y1, x2, y2+1);
|
||||
dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DHIGHLIGHT));
|
||||
dc.DrawLine(x1-1, y2+1, x2+1, y2+1);
|
||||
dc.DrawLine(x2+1, y1-1, x2+1, y2+2);
|
||||
}
|
||||
|
||||
void draw_control_border(Window* win, DC& dc, const wxRect& rect) {
|
||||
#if defined(wxMSW) && wxUSE_UXTHEME
|
||||
RECT r;
|
||||
wxUxThemeEngine *themeEngine = wxUxThemeEngine::Get();
|
||||
if (themeEngine && themeEngine->IsAppThemed()) {
|
||||
wxUxThemeHandle hTheme(win, L_("EDIT"));
|
||||
r.left = rect.x -1;
|
||||
r.top = rect.y -1;
|
||||
r.right = rect.x + rect.width + 1;
|
||||
r.bottom = rect.y + rect.height + 1;
|
||||
if (hTheme) {
|
||||
wxUxThemeEngine::Get()->DrawThemeBackground(
|
||||
hTheme,
|
||||
dc.GetHDC(),
|
||||
EP_EDITTEXT,
|
||||
ETS_NORMAL,
|
||||
&r,
|
||||
NULL
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
r.left = rect.x - 2;
|
||||
r.top = rect.y - 2;
|
||||
r.right = rect.x + rect.width + 2;
|
||||
r.bottom = rect.y + rect.height + 2;
|
||||
DrawEdge((HDC)dc.GetHDC(), &r, EDGE_SUNKEN, BF_RECT);
|
||||
#else
|
||||
draw3DBorder(dc, rect.x - 1, rect.y - 1, rect.x + rect.width, rect.y + rect.height);
|
||||
#endif
|
||||
}
|
||||
|
||||
+7
-1
@@ -29,7 +29,13 @@ void draw_checker(RotatedDC& dc, const RealRect&);
|
||||
// ----------------------------------------------------------------------------- : Resource related
|
||||
|
||||
/// Load an image from a resource
|
||||
Image load_resource_image(String name);
|
||||
Image load_resource_image(const String& name);
|
||||
|
||||
// ----------------------------------------------------------------------------- : Platform look
|
||||
|
||||
/// Draws a border for a control *around* a rect
|
||||
/** Based on wxRendererXP::DrawComboBoxDropButton */
|
||||
void draw_control_border(Window* win, DC& dc, const wxRect& rect);
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
#endif
|
||||
|
||||
@@ -95,6 +95,15 @@ 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
|
||||
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
|
||||
|
||||
@@ -404,6 +404,12 @@
|
||||
<File
|
||||
RelativePath=".\gui\control\graph.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gui\control\native_look_editor.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gui\control\native_look_editor.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gui\control\package_list.cpp">
|
||||
</File>
|
||||
|
||||
@@ -27,23 +27,26 @@ void DataViewer::draw(DC& dc) {
|
||||
StyleSheetP stylesheet = set->stylesheetFor(card);
|
||||
StyleSheetSettings& ss = settings.stylesheetSettingsFor(*stylesheet);
|
||||
RotatedDC rdc(dc, ss.card_angle(), stylesheet->getCardRect(), ss.card_zoom(), ss.card_anti_alias() && !nativeLook());
|
||||
draw(rdc);
|
||||
draw(rdc, set->stylesheet->card_background);
|
||||
}
|
||||
void DataViewer::draw(RotatedDC& dc) {
|
||||
void DataViewer::draw(RotatedDC& dc, const Color& background) {
|
||||
if (!set) return; // no set specified, don't draw anything
|
||||
// fill with background color
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
dc.SetBrush(set->stylesheet->card_background);
|
||||
dc.SetBrush(background);
|
||||
dc.DrawRectangle(dc.getInternalRect());
|
||||
// update style scripts
|
||||
if (card) set->updateFor(card);
|
||||
// draw values
|
||||
FOR_EACH(v, viewers) { // draw low z index fields first
|
||||
if (v->getStyle()->visible) {// visible
|
||||
v->draw(dc);
|
||||
drawViewer(dc, *v);
|
||||
}
|
||||
}
|
||||
}
|
||||
void DataViewer::drawViewer(RotatedDC& dc, ValueViewer& v) {
|
||||
v.draw(dc);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Utility for ValueViewers
|
||||
|
||||
@@ -80,8 +83,9 @@ void DataViewer::setStyles(IndexMap<FieldP,StyleP>& styles) {
|
||||
viewers.clear();
|
||||
FOR_EACH(s, styles) {
|
||||
if ((s->visible || s->visible.isScripted()) &&
|
||||
(s->width || s->width .isScripted()) &&
|
||||
(s->height || s->height .isScripted())) {
|
||||
nativeLook() || (
|
||||
(s->width || s->width .isScripted()) &&
|
||||
(s->height || s->height .isScripted()))) {
|
||||
// no need to make a viewer for things that are always invisible
|
||||
viewers.push_back(makeViewer(s));
|
||||
// REMOVEME //TODO //%%%
|
||||
|
||||
@@ -28,9 +28,11 @@ class DataViewer : public SetView {
|
||||
// --------------------------------------------------- : Drawing
|
||||
|
||||
/// Draw the current (card/data) to the given dc
|
||||
void draw(DC& dc);
|
||||
virtual void draw(DC& dc);
|
||||
/// Draw the current (card/data) to the given dc
|
||||
virtual void draw(RotatedDC& dc);
|
||||
virtual void draw(RotatedDC& dc, const Color& background);
|
||||
/// Draw a single viewer
|
||||
virtual void drawViewer(RotatedDC& dc, ValueViewer& v);
|
||||
|
||||
// --------------------------------------------------- : Utility for ValueViewers
|
||||
|
||||
|
||||
@@ -14,13 +14,13 @@ DECLARE_TYPEOF_COLLECTION(TextElementP);
|
||||
|
||||
// ----------------------------------------------------------------------------- : TextElements
|
||||
|
||||
void TextElements::draw(RotatedDC& dc, double scale, const RealRect& rect, double* xs, DrawWhat what, size_t start, size_t end) const {
|
||||
void TextElements::draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const {
|
||||
FOR_EACH_CONST(e, elements) {
|
||||
size_t start_ = max(start, e->start);
|
||||
size_t end_ = min(end, e->end);
|
||||
if (start_ < end_) {
|
||||
e->draw(dc, scale,
|
||||
RealRect(rect.position.x + xs[start_-start], rect.position.y,
|
||||
RealRect(rect.position.x + xs[start_-start] - xs[0], rect.position.y,
|
||||
xs[end_-start] - xs[start_-start], rect.size.height),
|
||||
xs + start_ - start, what, start_, end_);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ class TextElement {
|
||||
/// Draw a subsection section of the text in the given rectangle
|
||||
/** xs give the x coordinates for each character
|
||||
* this->start <= start < end <= this->end <= text.size() */
|
||||
virtual void draw (RotatedDC& dc, double scale, const RealRect& rect, double* xs, DrawWhat what, size_t start, size_t end) const = 0;
|
||||
virtual void draw (RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const = 0;
|
||||
/// Get information on all characters in the range [start...end) and store them in out
|
||||
virtual void getCharInfo(RotatedDC& dc, double scale, vector<CharInfo>& out) const = 0;
|
||||
/// Return the minimum scale factor allowed (starts at 1)
|
||||
@@ -96,7 +96,7 @@ class TextElement {
|
||||
class TextElements : public vector<TextElementP> {
|
||||
public:
|
||||
/// Draw all the elements (as need to show the range start..end)
|
||||
void draw (RotatedDC& dc, double scale, const RealRect& rect, double* xs, DrawWhat what, size_t start, size_t end) const;
|
||||
void draw (RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const;
|
||||
// Get information on all characters in the range [start...end) and store them in out
|
||||
void getCharInfo(RotatedDC& dc, double scale, size_t start, size_t end, vector<CharInfo>& out) const;
|
||||
/// Return the minimum scale factor allowed by all elements
|
||||
@@ -131,7 +131,7 @@ class FontTextElement : public SimpleTextElement {
|
||||
, font(font)
|
||||
{}
|
||||
|
||||
virtual void draw (RotatedDC& dc, double scale, const RealRect& rect, double* xs, DrawWhat what, size_t start, size_t end) const;
|
||||
virtual void draw (RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const;
|
||||
virtual void getCharInfo(RotatedDC& dc, double scale, vector<CharInfo>& out) const;
|
||||
virtual double minScale() const;
|
||||
private:
|
||||
@@ -147,7 +147,7 @@ class SymbolTextElement : public SimpleTextElement {
|
||||
, font(font), ctx(*ctx)
|
||||
{}
|
||||
|
||||
virtual void draw (RotatedDC& dc, double scale, const RealRect& rect, double* xs, DrawWhat what, size_t start, size_t end) const;
|
||||
virtual void draw (RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const;
|
||||
virtual void getCharInfo(RotatedDC& dc, double scale, vector<CharInfo>& out) const;
|
||||
virtual double minScale() const;
|
||||
private:
|
||||
@@ -172,7 +172,7 @@ class HorizontalLineTextElement : public TextElement {
|
||||
public:
|
||||
HorizontalLineTextElement(const String& text, size_t start ,size_t end) : TextElement(text, start, end) {}
|
||||
|
||||
virtual void draw (RotatedDC& dc, double scale, const RealRect& rect, double* xs, DrawWhat what, size_t start, size_t end) const;
|
||||
virtual void draw (RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const;
|
||||
virtual void getCharInfo(RotatedDC& dc, double scale, vector<CharInfo>& out) const;
|
||||
virtual double minScale() const;
|
||||
};
|
||||
@@ -185,7 +185,7 @@ class CompoundTextElement : public TextElement {
|
||||
public:
|
||||
CompoundTextElement(const String& text, size_t start ,size_t end) : TextElement(text, start, end) {}
|
||||
|
||||
virtual void draw (RotatedDC& dc, double scale, const RealRect& rect, double* xs, DrawWhat what, size_t start, size_t end) const;
|
||||
virtual void draw (RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const;
|
||||
virtual RealSize charSize(RotatedDC& dc, double scale, size_t index) const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : FontTextElement
|
||||
|
||||
void FontTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, double* xs, DrawWhat what, size_t start, size_t end) const {
|
||||
void FontTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const {
|
||||
dc.SetFont(font->font, font->size * scale);
|
||||
|
||||
if (end != start && text.substr(end-1, 1) == _("\n")) end -= 1; // don't draw the newline character at the end
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : HorizontalLineTextElement
|
||||
|
||||
void HorizontalLineTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, double* xs, DrawWhat what, size_t start, size_t end) const {
|
||||
void HorizontalLineTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const {
|
||||
// handled by TextViewer
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : SymbolTextElement
|
||||
|
||||
void SymbolTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, double* xs, DrawWhat what, size_t start, size_t end) const {
|
||||
void SymbolTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const {
|
||||
if (font.font) {
|
||||
font.font->draw(dc, ctx, rect, font.size * scale, font.alignment, text.substr(start, end-start));
|
||||
}
|
||||
|
||||
@@ -257,11 +257,11 @@ bool TextViewer::prepareLinesScale(RotatedDC& dc, const String& text, const Text
|
||||
}
|
||||
|
||||
double TextViewer::lineLeft(RotatedDC& dc, const TextStyle& style, double y) {
|
||||
return 0;
|
||||
return 0 + style.padding_left;
|
||||
// return style.mask.rowLeft(y, dc.getInternalSize()) + style.padding_left;
|
||||
}
|
||||
double TextViewer::lineRight(RotatedDC& dc, const TextStyle& style, double y) {
|
||||
return style.width;
|
||||
return style.width - style.padding_right;
|
||||
// return style.mask.rowRight(y, dc.getInternalSize()) - style.padding_right;
|
||||
}
|
||||
ContourMask::ContourMask() {} // MOVEME //@@
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <script/context.hpp>
|
||||
#include <util/dynamic_arg.hpp>
|
||||
#include <util/io/package.hpp>
|
||||
#include <gui/util.hpp> // load_resource_image
|
||||
|
||||
// image generating functions have two modes
|
||||
// if last_update_age > 0 they return whether the image is still up to date
|
||||
@@ -59,6 +60,10 @@ bool script_image_up_to_date(const ScriptValueP& value) {
|
||||
|
||||
// ----------------------------------------------------------------------------- : ScriptableImage
|
||||
|
||||
ScriptableImage::ScriptableImage(const String& script_)
|
||||
: script(script_)
|
||||
{}
|
||||
|
||||
ScriptImageP ScriptableImage::generate(Context& ctx, Package& pkg) const {
|
||||
try {
|
||||
WITH_DYNAMIC_ARG(load_images_from, &pkg);
|
||||
@@ -200,3 +205,21 @@ SCRIPT_FUNCTION(set_mask) {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
SCRIPT_FUNCTION(buildin_image) {
|
||||
if (last_update_age() == 0) {
|
||||
SCRIPT_PARAM(String, input);
|
||||
Image img = load_resource_image(input);
|
||||
if (!img.Ok()) throw ScriptError(_("There is no build in image '") + input + _("'"));
|
||||
return new_intrusive1<ScriptImage>(img);
|
||||
} else {
|
||||
SCRIPT_RETURN(true);
|
||||
}
|
||||
}
|
||||
|
||||
void init_script_image_functions(Context& ctx) {
|
||||
ctx.setVariable(_("linear blend"), script_linear_blend);
|
||||
ctx.setVariable(_("masked blend"), script_masked_blend);
|
||||
ctx.setVariable(_("set mask"), script_set_mask);
|
||||
ctx.setVariable(_("buildin image"), script_buildin_image);
|
||||
}
|
||||
|
||||
@@ -46,6 +46,9 @@ class ScriptImage : public ScriptValue {
|
||||
*/
|
||||
class ScriptableImage {
|
||||
public:
|
||||
inline ScriptableImage() {}
|
||||
ScriptableImage(const String& script);
|
||||
|
||||
/// Is there an image set?
|
||||
inline operator bool() const { return script; }
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ DECLARE_TYPEOF_NO_REV(IndexMap_FieldP_ValueP);
|
||||
|
||||
// initialize functions, from functions.cpp
|
||||
void init_script_functions(Context& ctx);
|
||||
void init_script_image_functions(Context& ctx);
|
||||
|
||||
// ----------------------------------------------------------------------------- : ScriptManager : initialization
|
||||
|
||||
@@ -57,6 +58,7 @@ Context& ScriptManager::getContext(const StyleSheetP& stylesheet) {
|
||||
// NOTE: do not use a smart pointer for the pointer to the set, because the set owns this
|
||||
// which would lead to a reference cycle.
|
||||
init_script_functions(*ctx);
|
||||
init_script_image_functions(*ctx);
|
||||
ctx->setVariable(_("set"), new_intrusive1<ScriptObject<Set*> >(&set));
|
||||
ctx->setVariable(_("game"), toScript(set.game));
|
||||
ctx->setVariable(_("stylesheet"), toScript(stylesheet));
|
||||
|
||||
@@ -23,6 +23,11 @@ void store(const ScriptValueP& val, Defaultable<String>& var) { var.assign(*val)
|
||||
|
||||
// ----------------------------------------------------------------------------- : OptionalScript
|
||||
|
||||
OptionalScript::OptionalScript(const String& script_)
|
||||
: unparsed(script_)
|
||||
, script(::parse(script_))
|
||||
{}
|
||||
|
||||
OptionalScript::~OptionalScript() {}
|
||||
|
||||
ScriptValueP OptionalScript::invoke(Context& ctx, bool open_scope) const {
|
||||
|
||||
@@ -33,6 +33,8 @@ void store(const ScriptValueP& val, Defaultable<String>& var);
|
||||
/// An optional script,
|
||||
class OptionalScript {
|
||||
public:
|
||||
inline OptionalScript() {}
|
||||
OptionalScript(const String& script_);
|
||||
~OptionalScript();
|
||||
/// Is the script set?
|
||||
inline operator bool() const { return !!script; }
|
||||
@@ -96,6 +98,8 @@ class Scriptable {
|
||||
inline operator const T& () const { return value; }
|
||||
inline const T& operator ()() const { return value; }
|
||||
inline bool isScripted() const { return script; }
|
||||
/// Has this value been read from a Reader?
|
||||
inline bool hasBeenRead() const { return !script.unparsed.empty(); }
|
||||
|
||||
/// Updates the value by executing the script, returns true if the value has changed
|
||||
inline bool update(Context& ctx) {
|
||||
|
||||
@@ -117,6 +117,14 @@ String capitalize(const String& s) {
|
||||
return result;
|
||||
}
|
||||
|
||||
String capitalize_sentence(const String& s) {
|
||||
String ret = s.Lower();
|
||||
if (!ret.empty()) {
|
||||
ret[0] = toUpper(ret[0]);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
String cannocial_name_form(const String& str) {
|
||||
String ret;
|
||||
ret.reserve(str.size());
|
||||
|
||||
Reference in New Issue
Block a user