mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-12 13:37:00 -04:00
Fixed TextCtrl to work for keyword properties;
Added wrapping of <> around parameters to TextElement; Added colors for keyword parameters; Added menu & toolbar for keyword panel; Fixed bug in package, save/save-as was the wrong way around; Added third quality setting to RotatedDC: using SetUserScale, this gets you more precise positioning. git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@250 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include <gui/control/card_viewer.hpp>
|
||||
|
||||
class ValueEditor;
|
||||
class FindInfo;
|
||||
|
||||
// ----------------------------------------------------------------------------- : DataEditor
|
||||
|
||||
@@ -58,6 +59,16 @@ class DataEditor : public CardViewer {
|
||||
/// A menu item from getMenu was selected
|
||||
void onCommand(int id);
|
||||
|
||||
// --------------------------------------------------- : Search/replace
|
||||
|
||||
/// Do a search or replace action for the given FindInfo
|
||||
/** If from_start == false: searches only from the current selection onward (or backward)
|
||||
* If from_start == true: searches everything
|
||||
*
|
||||
* Returns true when more searching is needed.
|
||||
*/
|
||||
bool search(FindInfo& find, bool from_start);
|
||||
|
||||
// --------------------------------------------------- : ValueViewers
|
||||
|
||||
protected:
|
||||
|
||||
@@ -246,7 +246,7 @@ void GraphControl::setData(const GraphDataP& data) {
|
||||
void GraphControl::onPaint(wxPaintEvent&) {
|
||||
wxBufferedPaintDC dc(this);
|
||||
wxSize cs = GetClientSize();
|
||||
RotatedDC rdc(dc, 0, RealRect(RealPoint(0,0),cs), 1, false);
|
||||
RotatedDC rdc(dc, 0, RealRect(RealPoint(0,0),cs), 1, QUALITY_LOW);
|
||||
rdc.SetPen(*wxTRANSPARENT_PEN);
|
||||
rdc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
rdc.DrawRectangle(rdc.getInternalRect());
|
||||
|
||||
@@ -26,7 +26,7 @@ Rotation NativeLookEditor::getRotation() const {
|
||||
}
|
||||
|
||||
void NativeLookEditor::draw(DC& dc) {
|
||||
RotatedDC rdc(dc, getRotation(), false);
|
||||
RotatedDC rdc(dc, getRotation(), QUALITY_LOW);
|
||||
DataViewer::draw(rdc, wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
|
||||
}
|
||||
void NativeLookEditor::drawViewer(RotatedDC& dc, ValueViewer& v) {
|
||||
|
||||
@@ -16,9 +16,10 @@ DECLARE_TYPEOF_COLLECTION(ValueViewerP);
|
||||
|
||||
// ----------------------------------------------------------------------------- : TextCtrl
|
||||
|
||||
TextCtrl::TextCtrl(Window* parent, int id, long style)
|
||||
TextCtrl::TextCtrl(Window* parent, int id, bool multi_line, long style)
|
||||
: DataEditor(parent, id, style)
|
||||
, value(nullptr)
|
||||
, multi_line(multi_line)
|
||||
{}
|
||||
|
||||
Rotation TextCtrl::getRotation() const {
|
||||
@@ -26,44 +27,37 @@ Rotation TextCtrl::getRotation() const {
|
||||
}
|
||||
|
||||
void TextCtrl::draw(DC& dc) {
|
||||
RotatedDC rdc(dc, getRotation(), false);
|
||||
RotatedDC rdc(dc, getRotation(), QUALITY_LOW);
|
||||
DataViewer::draw(rdc, wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
}
|
||||
|
||||
|
||||
void TextCtrl::setValue(String* value) {
|
||||
this->value = value;
|
||||
if (viewers.empty() && value) {
|
||||
// create a field, style and value
|
||||
TextFieldP field(new TextField);
|
||||
TextStyleP style(new TextStyle(field));
|
||||
TextValueP value(new FakeTextValue(field, this->value));
|
||||
// set stuff
|
||||
field->index = 0;
|
||||
field->multi_line = true;
|
||||
style->width = 100;
|
||||
style->height = 20;
|
||||
style->left = style->top = 1;
|
||||
value->value.assign(*this->value);
|
||||
// assign to this control
|
||||
IndexMap<FieldP,StyleP> styles; styles.add(field, style);
|
||||
IndexMap<FieldP,ValueP> values; values.add(field, value);
|
||||
setStyles(set->stylesheet, styles);
|
||||
setData(values);
|
||||
// determine size
|
||||
wxSize cs = GetClientSize();
|
||||
style->width = cs.GetWidth() - 2;
|
||||
style->height = cs.GetHeight() - 2;
|
||||
viewers.front()->getEditor()->determineSize(true);
|
||||
// We don't wan to change the window size
|
||||
//SetMinSize(RealSize(style->width + 6, style->height + 6));
|
||||
} else if (value) {
|
||||
TextStyle& TextCtrl::getStyle() {
|
||||
assert(!viewers.empty());
|
||||
return static_cast<TextStyle&>(*viewers.front()->getStyle());
|
||||
}
|
||||
TextField& TextCtrl::getField() {
|
||||
assert(!viewers.empty());
|
||||
return static_cast<TextField&>(*viewers.front()->getField());
|
||||
}
|
||||
void TextCtrl::updateSize() {
|
||||
wxSize cs = GetClientSize();
|
||||
Style& style = getStyle();
|
||||
style.width = cs.GetWidth() - 2;
|
||||
style.height = cs.GetHeight() - 2;
|
||||
viewers.front()->getEditor()->determineSize(true);
|
||||
}
|
||||
|
||||
void TextCtrl::setValue(String* value, bool untagged) {
|
||||
if (value != this->value) {
|
||||
this->value = value;
|
||||
// create a new value, for a different underlying actual value
|
||||
ValueViewer& viewer = *viewers.front();
|
||||
TextValueP new_value(new FakeTextValue(static_pointer_cast<TextField>(viewer.getField()), this->value));
|
||||
ValueViewer& viewer = *viewers.front();
|
||||
TextValueP new_value(new FakeTextValue(static_pointer_cast<TextField>(viewer.getField()), this->value, untagged));
|
||||
viewer.setValue(new_value);
|
||||
updateSize();
|
||||
valueChanged();
|
||||
}
|
||||
valueChanged();
|
||||
}
|
||||
void TextCtrl::valueChanged() {
|
||||
if (!viewers.empty()) {
|
||||
@@ -87,7 +81,29 @@ void TextCtrl::onAction(const Action& action, bool undone) {
|
||||
}
|
||||
void TextCtrl::onChangeSet() {
|
||||
DataEditor::onChangeSet();
|
||||
setValue(nullptr);
|
||||
// initialize
|
||||
if (viewers.empty()) {
|
||||
// create a field, style and value
|
||||
TextFieldP field(new TextField);
|
||||
TextStyleP style(new TextStyle(field));
|
||||
TextValueP value(new FakeTextValue(field, nullptr, false));
|
||||
// set stuff
|
||||
field->index = 0;
|
||||
field->multi_line = multi_line;
|
||||
style->width = 100;
|
||||
style->height = 20;
|
||||
style->left = style->top = 1;
|
||||
style->font.color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
|
||||
// assign to this control
|
||||
IndexMap<FieldP,StyleP> styles; styles.add(field, style);
|
||||
IndexMap<FieldP,ValueP> values; values.add(field, value);
|
||||
setStyles(set->stylesheet, styles);
|
||||
setData(values);
|
||||
updateSize();
|
||||
onChange();
|
||||
} else {
|
||||
setValue(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void TextCtrl::onInit() {
|
||||
@@ -99,16 +115,19 @@ void TextCtrl::onInit() {
|
||||
|
||||
void TextCtrl::onSize(wxSizeEvent&) {
|
||||
if (!viewers.empty()) {
|
||||
wxSize cs = GetClientSize();
|
||||
Style& style = *viewers.front()->getStyle();
|
||||
style.width = cs.GetWidth() - 2;
|
||||
style.height = cs.GetHeight() - 2;
|
||||
viewers.front()->getEditor()->determineSize(true);
|
||||
updateSize();
|
||||
onChange();
|
||||
}
|
||||
onChange();
|
||||
}
|
||||
wxSize TextCtrl::DoGetBestSize() const {
|
||||
return wxSize(1,1);
|
||||
if (multi_line || viewers.empty()) {
|
||||
// flexible size
|
||||
return wxSize(1,1);
|
||||
} else {
|
||||
wxSize ws = GetSize(), cs = GetClientSize();
|
||||
Style& style = *viewers.front()->getStyle();
|
||||
return wxSize(style.width, style.height) + ws - cs;
|
||||
}
|
||||
}
|
||||
|
||||
BEGIN_EVENT_TABLE(TextCtrl, DataEditor)
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
#include <util/prec.hpp>
|
||||
#include <gui/control/card_editor.hpp>
|
||||
|
||||
class TextField;
|
||||
class TextStyle;
|
||||
|
||||
// ----------------------------------------------------------------------------- : TextCtrl
|
||||
|
||||
/// A control for editing a String
|
||||
@@ -25,13 +28,20 @@
|
||||
*/
|
||||
class TextCtrl : public DataEditor {
|
||||
public:
|
||||
TextCtrl(Window* parent, int id, long style = 0);
|
||||
TextCtrl(Window* parent, int id, bool multi_line, long style = 0);
|
||||
|
||||
/// Set the value that is being edited
|
||||
void setValue(String* value);
|
||||
void setValue(String* value, bool untagged = false);
|
||||
/// Notification that the value has changed outside this control
|
||||
void valueChanged();
|
||||
|
||||
/// Get access to the field used by the control
|
||||
TextField& getField();
|
||||
/// Get access to the style used by the control
|
||||
TextStyle& getStyle();
|
||||
/// Update the size, for example after changing the style
|
||||
void updateSize();
|
||||
|
||||
/// Uses a native look
|
||||
virtual bool nativeLook() const { return true; }
|
||||
virtual bool drawBorders() const { return false; }
|
||||
@@ -48,7 +58,8 @@ class TextCtrl : public DataEditor {
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
|
||||
private:
|
||||
String* value; ///< Value to edit
|
||||
String* value; ///< Value to edit
|
||||
bool multi_line; ///< Multi line text control?
|
||||
|
||||
DECLARE_EVENT_TABLE();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user