mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-12 21:47:00 -04:00
Allow ValueViewers to have a bounding box different from the Style's. This closes #64.
This commit is contained in:
@@ -189,15 +189,6 @@ int Style::update(Context& ctx) {
|
|||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Style::isVisible() const {
|
|
||||||
return visible
|
|
||||||
&& (width()) > 0
|
|
||||||
&& fabs(left()) < 100000
|
|
||||||
&& fabs(right()) < 100000
|
|
||||||
&& (height()) > 0
|
|
||||||
&& fabs(top()) < 100000
|
|
||||||
&& fabs(bottom()) < 100000;
|
|
||||||
}
|
|
||||||
bool Style::hasSize() const {
|
bool Style::hasSize() const {
|
||||||
int h = is_setw(width) + is_set(left) + is_set(right);
|
int h = is_setw(width) + is_set(left) + is_set(right);
|
||||||
int v = is_setw(height) + is_set(top) + is_set(bottom);
|
int v = is_setw(height) + is_set(top) + is_set(bottom);
|
||||||
|
|||||||
+3
-6
@@ -118,15 +118,12 @@ public:
|
|||||||
} automatic_side : 8; ///< Which of (left, width, right) and (top, height, bottom) is determined automatically?
|
} automatic_side : 8; ///< Which of (left, width, right) and (top, height, bottom) is determined automatically?
|
||||||
bool content_dependent; ///< Does this style depend on content properties?
|
bool content_dependent; ///< Does this style depend on content properties?
|
||||||
|
|
||||||
inline RealPoint getPos() const { return RealPoint(left, top ); }
|
inline RealPoint getPos() const { return RealPoint(left, top); }
|
||||||
inline RealSize getSize() const { return RealSize ( width, height); }
|
inline RealSize getSize() const { return RealSize(width, height); }
|
||||||
inline RealRect getExternalRect() const { return RealRect (left, top, width, height); }
|
inline RealRect getExternalRect() const { return RealRect(left, top, width, height); }
|
||||||
inline RealRect getInternalRect() const { return RealRect(0, 0, width, height); }
|
|
||||||
|
|
||||||
/// Does this style have a non-zero size (or is it scripted)?
|
/// Does this style have a non-zero size (or is it scripted)?
|
||||||
bool hasSize() const;
|
bool hasSize() const;
|
||||||
/// Is this style visible, and does it have a sane size
|
|
||||||
bool isVisible() const;
|
|
||||||
|
|
||||||
/// Get a copy of this style
|
/// Get a copy of this style
|
||||||
virtual StyleP clone() const = 0;
|
virtual StyleP clone() const = 0;
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ struct CompareTabOrder {
|
|||||||
};
|
};
|
||||||
|
|
||||||
bool is_enabled(ValueViewerP const& v) {
|
bool is_enabled(ValueViewerP const& v) {
|
||||||
return v->getField()->editable && v->getStyle()->isVisible();
|
return v->getField()->editable && v->isVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DataEditor::selectWithTab(vector<ValueViewerP>::iterator const& it) {
|
bool DataEditor::selectWithTab(vector<ValueViewerP>::iterator const& it) {
|
||||||
@@ -210,7 +210,7 @@ bool DataEditor::search(Iterator it, Iterator end, FindInfo& find, bool from_sta
|
|||||||
for (;it != end; ++it) {
|
for (;it != end; ++it) {
|
||||||
ValueViewer* viewer = *it;
|
ValueViewer* viewer = *it;
|
||||||
if (viewer == current_viewer) include = true;
|
if (viewer == current_viewer) include = true;
|
||||||
if (include && viewer->getField()->editable && viewer->getStyle()->isVisible()) {
|
if (include && viewer->getField()->editable && viewer->isVisible()) {
|
||||||
ValueEditor* editor = viewer->getEditor();
|
ValueEditor* editor = viewer->getEditor();
|
||||||
if (editor) {
|
if (editor) {
|
||||||
if (editor && editor->search(find, from_start || viewer != current_viewer)) {
|
if (editor && editor->search(find, from_start || viewer != current_viewer)) {
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ void CardViewer::redraw(const ValueViewer& v) {
|
|||||||
// causing the two viewers to continously refresh.
|
// causing the two viewers to continously refresh.
|
||||||
if (drawing_card()) return;
|
if (drawing_card()) return;
|
||||||
up_to_date = false;
|
up_to_date = false;
|
||||||
RefreshRect(getRotation().trRectToBB(v.boundingBox()), false);
|
RefreshRect(getRotation().trRectToBB(v.boundingBoxBorder()), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CardViewer::onChange() {
|
void CardViewer::onChange() {
|
||||||
@@ -112,7 +112,7 @@ bool CardViewer::shouldDraw(const ValueViewer& v) const {
|
|||||||
// int dx = GetScrollPos(wxHORIZONTAL), dy = GetScrollPos(wxVERTICAL);
|
// int dx = GetScrollPos(wxHORIZONTAL), dy = GetScrollPos(wxVERTICAL);
|
||||||
// wxRegion clip = GetUpdateRegion();
|
// wxRegion clip = GetUpdateRegion();
|
||||||
// clip.Offset(dx, dy);
|
// clip.Offset(dx, dy);
|
||||||
return GetUpdateRegion().Contains(getRotation().trRectToBB(v.boundingBox().toRect()).toRect()) != wxOutRegion;
|
return GetUpdateRegion().Contains(getRotation().trRectToBB(v.boundingBoxBorder().toRect()).toRect()) != wxOutRegion;
|
||||||
}
|
}
|
||||||
|
|
||||||
// helper class for overdrawDC()
|
// helper class for overdrawDC()
|
||||||
|
|||||||
@@ -35,14 +35,13 @@ void NativeLookEditor::drawViewer(RotatedDC& dc, ValueViewer& v) {
|
|||||||
ValueEditor* e = v.getEditor();
|
ValueEditor* e = v.getEditor();
|
||||||
if (!e || e->drawLabel()) {
|
if (!e || e->drawLabel()) {
|
||||||
// draw control border and box
|
// draw control border and box
|
||||||
Style& s = *v.getStyle();
|
draw_control_box(this, dc.getDC(), dc.getExternalRect().grow(1), current_editor == e, e != nullptr);
|
||||||
draw_control_box(this, dc.getDC(), dc.trRectToBB(s.getInternalRect().grow(1)), current_editor == e, e != nullptr);
|
|
||||||
// draw label
|
// draw label
|
||||||
dc.SetFont(*wxNORMAL_FONT);
|
dc.SetFont(*wxNORMAL_FONT);
|
||||||
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT));
|
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT));
|
||||||
// TODO : tr using stylesheet or using game?
|
// TODO : tr using stylesheet or using game?
|
||||||
dc.DrawText(tr(getStylePackage(), s.fieldP->caption, identity),
|
dc.DrawText(tr(getStylePackage(), v.getField()->caption, identity),
|
||||||
RealPoint(margin_left - s.left, 1));
|
RealPoint(margin_left - v.bounding_box.x, 1));
|
||||||
}
|
}
|
||||||
// draw viewer
|
// draw viewer
|
||||||
v.draw(dc);
|
v.draw(dc);
|
||||||
@@ -76,15 +75,15 @@ void NativeLookEditor::resizeViewers() {
|
|||||||
StyleP s = v->getStyle();
|
StyleP s = v->getStyle();
|
||||||
ValueEditor* e = v->getEditor();
|
ValueEditor* e = v->getEditor();
|
||||||
if (!e || e->drawLabel()) {
|
if (!e || e->drawLabel()) {
|
||||||
s->left = margin + label_width;
|
v->bounding_box.x = margin + label_width;
|
||||||
} else {
|
} else {
|
||||||
s->left = margin;
|
v->bounding_box.x = margin;
|
||||||
}
|
}
|
||||||
s->top = y;
|
v->bounding_box.y = y;
|
||||||
s->width = w - s->left - margin;
|
v->bounding_box.width = w - v->bounding_box.x - margin;
|
||||||
s->height = default_height;
|
v->bounding_box.height = s->height() == 0 ? default_height : s->height;
|
||||||
if (e) e->determineSize();
|
if (e) e->determineSize();
|
||||||
y += s->height + vspace;
|
y += v->bounding_box.height + vspace;
|
||||||
}
|
}
|
||||||
y = y - vspace + margin;
|
y = y - vspace + margin;
|
||||||
SetVirtualSize(w, (int)y);
|
SetVirtualSize(w, (int)y);
|
||||||
@@ -93,17 +92,6 @@ void NativeLookEditor::resizeViewers() {
|
|||||||
}
|
}
|
||||||
if (y >= h) {
|
if (y >= h) {
|
||||||
// Doesn't fit vertically, add scrollbar and resize
|
// Doesn't fit vertically, add scrollbar and resize
|
||||||
/*
|
|
||||||
y = margin;
|
|
||||||
FOR_EACH(v, viewers) {
|
|
||||||
StyleP s = v->getStyle();
|
|
||||||
ValueEditor* e = v->getEditor();
|
|
||||||
s->top = y;
|
|
||||||
s->width = s->width - wxSystemSettings::GetMetric(wxSYS_VSCROLL_X, this);
|
|
||||||
if (e) e->determineSize();
|
|
||||||
y += s->height + vspace;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
// create scrollbar
|
// create scrollbar
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,9 +55,9 @@ TextFieldP TextCtrl::getFieldP() {
|
|||||||
}
|
}
|
||||||
void TextCtrl::updateSize() {
|
void TextCtrl::updateSize() {
|
||||||
wxSize cs = GetClientSize();
|
wxSize cs = GetClientSize();
|
||||||
Style& style = getStyle();
|
ValueViewer& viewer = *viewers.front();
|
||||||
style.width = cs.GetWidth() - 2;
|
viewer.bounding_box.width = cs.GetWidth() - 2;
|
||||||
style.height = cs.GetHeight() - 2;
|
viewer.bounding_box.height = cs.GetHeight() - 2;
|
||||||
viewers.front()->getEditor()->determineSize(true);
|
viewers.front()->getEditor()->determineSize(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,9 +76,9 @@ void TextCtrl::onChangeSet() {
|
|||||||
// initialize
|
// initialize
|
||||||
if (viewers.empty()) {
|
if (viewers.empty()) {
|
||||||
// create a field, style and value
|
// create a field, style and value
|
||||||
TextFieldP field(new TextField);
|
TextFieldP field = make_intrusive<TextField>();
|
||||||
TextStyleP style(new TextStyle(field));
|
TextStyleP style = make_intrusive<TextStyle>(field);
|
||||||
TextValueP value(new FakeTextValue(field, nullptr, false, false));
|
TextValueP value = make_intrusive<FakeTextValue>(field, nullptr, false, false);
|
||||||
// set stuff
|
// set stuff
|
||||||
field->index = 0;
|
field->index = 0;
|
||||||
field->multi_line = multi_line;
|
field->multi_line = multi_line;
|
||||||
|
|||||||
@@ -287,7 +287,7 @@ void DropDownList::redrawArrowOnParent() {
|
|||||||
shared_ptr<RotatedDC> dcP = editor.overdrawDC();
|
shared_ptr<RotatedDC> dcP = editor.overdrawDC();
|
||||||
RotatedDC& dc = *dcP;
|
RotatedDC& dc = *dcP;
|
||||||
Rotater r(dc, viewer->getRotation());
|
Rotater r(dc, viewer->getRotation());
|
||||||
draw_drop_down_arrow(&editor, dc.getDC(), dc.trRectToBB(dc.getInternalRect().grow(1)), IsShown());
|
draw_drop_down_arrow(&editor, dc.getDC(), dc.getExternalRect().grow(1), IsShown());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -275,11 +275,11 @@ void ChoiceValueEditor::onLoseFocus() {
|
|||||||
void ChoiceValueEditor::draw(RotatedDC& dc) {
|
void ChoiceValueEditor::draw(RotatedDC& dc) {
|
||||||
ChoiceValueViewer::draw(dc);
|
ChoiceValueViewer::draw(dc);
|
||||||
if (nativeLook()) {
|
if (nativeLook()) {
|
||||||
draw_drop_down_arrow(&editor(), dc.getDC(), dc.trRectToBB(style().getInternalRect().grow(1)), drop_down->IsShown());
|
draw_drop_down_arrow(&editor(), dc.getDC(), dc.getExternalRect().grow(1), drop_down->IsShown());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void ChoiceValueEditor::determineSize(bool) {
|
void ChoiceValueEditor::determineSize(bool) {
|
||||||
style().height = max(style().height(), 16.);
|
bounding_box.height = max(bounding_box.height, 16.);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChoiceValueEditor::change(const Defaultable<String>& c) {
|
void ChoiceValueEditor::change(const Defaultable<String>& c) {
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ void ColorValueEditor::draw(RotatedDC& dc) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
void ColorValueEditor::determineSize(bool) {
|
void ColorValueEditor::determineSize(bool) {
|
||||||
style().height = 20;
|
bounding_box.height = 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorValueEditor::change(const Defaultable<Color>& c) {
|
void ColorValueEditor::change(const Defaultable<Color>& c) {
|
||||||
|
|||||||
@@ -14,5 +14,5 @@
|
|||||||
IMPLEMENT_VALUE_EDITOR(Info) {}
|
IMPLEMENT_VALUE_EDITOR(Info) {}
|
||||||
|
|
||||||
void InfoValueEditor::determineSize(bool) {
|
void InfoValueEditor::determineSize(bool) {
|
||||||
style().height = 26;
|
bounding_box.height = 26;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ void MultipleChoiceValueEditor::determineSize(bool force_fit) {
|
|||||||
item_height = 18;
|
item_height = 18;
|
||||||
// height depends on number of items and item height
|
// height depends on number of items and item height
|
||||||
int item_count = field().choices->lastId();
|
int item_count = field().choices->lastId();
|
||||||
style().height = item_count * item_height;
|
bounding_box.height = item_count * item_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MultipleChoiceValueEditor::onLeftDown(const RealPoint& pos, wxMouseEvent& ev) {
|
bool MultipleChoiceValueEditor::onLeftDown(const RealPoint& pos, wxMouseEvent& ev) {
|
||||||
|
|||||||
@@ -101,11 +101,11 @@ void PackageChoiceValueEditor::onLoseFocus() {
|
|||||||
void PackageChoiceValueEditor::draw(RotatedDC& dc) {
|
void PackageChoiceValueEditor::draw(RotatedDC& dc) {
|
||||||
PackageChoiceValueViewer::draw(dc);
|
PackageChoiceValueViewer::draw(dc);
|
||||||
if (nativeLook()) {
|
if (nativeLook()) {
|
||||||
draw_drop_down_arrow(&editor(), dc.getDC(), dc.trRectToBB(style().getInternalRect().grow(1)), drop_down && drop_down->IsShown());
|
draw_drop_down_arrow(&editor(), dc.getDC(), dc.getExternalRect().grow(1), drop_down && drop_down->IsShown());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void PackageChoiceValueEditor::determineSize(bool) {
|
void PackageChoiceValueEditor::determineSize(bool) {
|
||||||
style().height = max(style().height(), 16.);
|
bounding_box.height = max(bounding_box.height, 16.);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackageChoiceValueEditor::change(const String& c) {
|
void PackageChoiceValueEditor::change(const String& c) {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ void SymbolValueEditor::draw(RotatedDC& dc) {
|
|||||||
dc.SetFont(wxFont(10,wxFONTFAMILY_SWISS,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_NORMAL));
|
dc.SetFont(wxFont(10,wxFONTFAMILY_SWISS,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_NORMAL));
|
||||||
dc.SetTextForeground(*wxBLACK);
|
dc.SetTextForeground(*wxBLACK);
|
||||||
RealSize text_size = dc.GetTextExtent(_("double click to edit symbol"));
|
RealSize text_size = dc.GetTextExtent(_("double click to edit symbol"));
|
||||||
dc.DrawText(_("double click to edit symbol"), align_in_rect(ALIGN_MIDDLE_CENTER, text_size, style().getInternalRect()));
|
dc.DrawText(_("double click to edit symbol"), align_in_rect(ALIGN_MIDDLE_CENTER, text_size, dc.getInternalRect()));
|
||||||
}
|
}
|
||||||
if (nativeLook()) {
|
if (nativeLook()) {
|
||||||
// draw editor buttons
|
// draw editor buttons
|
||||||
@@ -38,9 +38,9 @@ void SymbolValueEditor::draw(RotatedDC& dc) {
|
|||||||
}
|
}
|
||||||
void SymbolValueEditor::drawButton(RotatedDC& dc, int button, const String& text) {
|
void SymbolValueEditor::drawButton(RotatedDC& dc, int button, const String& text) {
|
||||||
bool down = button == button_down;
|
bool down = button == button_down;
|
||||||
double height = style().height;
|
double height = bounding_box.height;
|
||||||
double width = style().height + 2;
|
double width = bounding_box.height + 2;
|
||||||
double x = style().width - width - (width + 1) * button;
|
double x = bounding_box.width - width - (width + 1) * button;
|
||||||
double y = 0;
|
double y = 0;
|
||||||
// draw button
|
// draw button
|
||||||
draw_button(&editor(), dc.getDC(), dc.trRectToBB(RealRect(x,y,width,height)), false, down, true);
|
draw_button(&editor(), dc.getDC(), dc.trRectToBB(RealRect(x,y,width,height)), false, down, true);
|
||||||
@@ -54,8 +54,8 @@ void SymbolValueEditor::drawButton(RotatedDC& dc, int button, const String& text
|
|||||||
}
|
}
|
||||||
|
|
||||||
int SymbolValueEditor::findButton(const RealPoint& pos) {
|
int SymbolValueEditor::findButton(const RealPoint& pos) {
|
||||||
if (pos.y < 0 || pos.y >= style().height) return -1;
|
if (pos.y < 0 || pos.y >= bounding_box.height) return -1;
|
||||||
int button = (int)floor( (style().width - pos.x) / (style().height + 3) );
|
int button = (int)floor( (bounding_box.width - pos.x) / (bounding_box.height + 3) );
|
||||||
if (button >= 0 && button <= 1) return button;
|
if (button >= 0 && button <= 1) return button;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -107,7 +107,8 @@ bool SymbolValueEditor::onLeftDClick(const RealPoint& pos, wxMouseEvent&) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SymbolValueEditor::determineSize(bool) {
|
void SymbolValueEditor::determineSize(bool) {
|
||||||
style().height = 50;
|
if (style().height == 0) style().height = 50;
|
||||||
|
bounding_box.height = 50;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+10
-8
@@ -627,7 +627,7 @@ wxMenu* TextValueEditor::getMenu(int type) const {
|
|||||||
void TextValueEditor::draw(RotatedDC& dc) {
|
void TextValueEditor::draw(RotatedDC& dc) {
|
||||||
if (nativeLook()) {
|
if (nativeLook()) {
|
||||||
// clip the dc to the region of this control
|
// clip the dc to the region of this control
|
||||||
dc.SetClippingRegion(style().getInternalRect());
|
dc.SetClippingRegion(dc.getInternalRect());
|
||||||
}
|
}
|
||||||
// update scrollbar
|
// update scrollbar
|
||||||
prepareDrawScrollbar(dc);
|
prepareDrawScrollbar(dc);
|
||||||
@@ -663,7 +663,7 @@ void TextValueEditor::redrawSelection(size_t old_selection_start_i, size_t old_s
|
|||||||
Rotater r(dc, getRotation());
|
Rotater r(dc, getRotation());
|
||||||
if (nativeLook()) {
|
if (nativeLook()) {
|
||||||
// clip the dc to the region of this control
|
// clip the dc to the region of this control
|
||||||
dc.SetClippingRegion(style().getInternalRect());
|
dc.SetClippingRegion(dc.getInternalRect());
|
||||||
}
|
}
|
||||||
// clear old selection by drawing it again
|
// clear old selection by drawing it again
|
||||||
if (!old_drop_down_shown) {
|
if (!old_drop_down_shown) {
|
||||||
@@ -727,9 +727,8 @@ bool TextValueEditor::containsPoint(const RealPoint& pos) const {
|
|||||||
if (word_lists.empty()) return false;
|
if (word_lists.empty()) return false;
|
||||||
return (bool) findWordList(pos);
|
return (bool) findWordList(pos);
|
||||||
}
|
}
|
||||||
RealRect TextValueEditor::boundingBox() const {
|
RealRect TextValueEditor::boundingBoxBorder() const {
|
||||||
if (word_lists.empty()) return ValueViewer::boundingBox();
|
RealRect r = ValueViewer::boundingBoxBorder();
|
||||||
RealRect r = style().getInternalRect().grow(1);
|
|
||||||
FOR_EACH_CONST(wl, word_lists) {
|
FOR_EACH_CONST(wl, word_lists) {
|
||||||
r.width = max(r.width, wl->rect.right() + 9);
|
r.width = max(r.width, wl->rect.right() + 9);
|
||||||
}
|
}
|
||||||
@@ -1255,14 +1254,16 @@ void TextValueEditor::determineSize(bool force_fit) {
|
|||||||
// muliline, determine scrollbar size
|
// muliline, determine scrollbar size
|
||||||
Rotation rot = parent.getRotation();
|
Rotation rot = parent.getRotation();
|
||||||
Rotater r(rot, getRotation());
|
Rotater r(rot, getRotation());
|
||||||
if (!force_fit) style().height = 100;
|
if (!force_fit) {
|
||||||
|
style().height = bounding_box.height = 100;
|
||||||
|
}
|
||||||
int sbw = wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
|
int sbw = wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
|
||||||
RealPoint pos = rot.tr(RealPoint(0,0));
|
RealPoint pos = rot.tr(RealPoint(0,0));
|
||||||
scrollbar->SetSize(
|
scrollbar->SetSize(
|
||||||
(int)(pos.x + rot.trX(style().width) + 1 - sbw),
|
(int)(pos.x + rot.trX(bounding_box.width) + 1 - sbw),
|
||||||
(int)pos.y - 1,
|
(int)pos.y - 1,
|
||||||
(int)sbw,
|
(int)sbw,
|
||||||
(int)rot.trY(style().height) + 2);
|
(int)rot.trY(bounding_box.height) + 2);
|
||||||
v.reset(true);
|
v.reset(true);
|
||||||
} else {
|
} else {
|
||||||
// Height depends on font
|
// Height depends on font
|
||||||
@@ -1272,6 +1273,7 @@ void TextValueEditor::determineSize(bool force_fit) {
|
|||||||
dc.SetFont(style().font.toWxFont(1.0));
|
dc.SetFont(style().font.toWxFont(1.0));
|
||||||
style().height = dc.GetCharHeight() + 2 + style().padding_top + style().padding_bottom;
|
style().height = dc.GetCharHeight() + 2 + style().padding_top + style().padding_bottom;
|
||||||
}
|
}
|
||||||
|
bounding_box.height = style().height;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextValueEditor::onShow(bool showing) {
|
void TextValueEditor::onShow(bool showing) {
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public:
|
|||||||
wxCursor cursor(const RealPoint& pos) const override;
|
wxCursor cursor(const RealPoint& pos) const override;
|
||||||
void determineSize(bool force_fit = false) override;
|
void determineSize(bool force_fit = false) override;
|
||||||
bool containsPoint(const RealPoint& p) const override;
|
bool containsPoint(const RealPoint& p) const override;
|
||||||
RealRect boundingBox() const override;
|
RealRect boundingBoxBorder() const override;
|
||||||
void onShow(bool) override;
|
void onShow(bool) override;
|
||||||
void draw(RotatedDC&) override;
|
void draw(RotatedDC&) override;
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ void DataViewer::draw(RotatedDC& dc, const Color& background) {
|
|||||||
// prepare viewers
|
// prepare viewers
|
||||||
bool changed_content_properties = false;
|
bool changed_content_properties = false;
|
||||||
FOR_EACH(v, viewers) { // draw low z index fields first
|
FOR_EACH(v, viewers) { // draw low z index fields first
|
||||||
if (v->getStyle()->isVisible()) {
|
if (v->isVisible()) {
|
||||||
Rotater r(dc, v->getRotation());
|
Rotater r(dc, v->getRotation());
|
||||||
try {
|
try {
|
||||||
if (v->prepare(dc)) {
|
if (v->prepare(dc)) {
|
||||||
@@ -59,7 +59,7 @@ void DataViewer::draw(RotatedDC& dc, const Color& background) {
|
|||||||
}
|
}
|
||||||
// draw viewers
|
// draw viewers
|
||||||
FOR_EACH(v, viewers) { // draw low z index fields first
|
FOR_EACH(v, viewers) { // draw low z index fields first
|
||||||
if (v->getStyle()->isVisible()) {// visible
|
if (v->isVisible()) {// visible
|
||||||
Rotater r(dc, v->getRotation());
|
Rotater r(dc, v->getRotation());
|
||||||
try {
|
try {
|
||||||
drawViewer(dc, *v);
|
drawViewer(dc, *v);
|
||||||
|
|||||||
@@ -546,7 +546,7 @@ void TextViewer::prepareLinesTryScales(RotatedDC& dc, const String& text, const
|
|||||||
// Try to fit a blank line in the masked image, move down until it fits
|
// Try to fit a blank line in the masked image, move down until it fits
|
||||||
RealSize TextViewer::fitLineWidth(Line& line, RotatedDC& dc, const TextStyle& style) const {
|
RealSize TextViewer::fitLineWidth(Line& line, RotatedDC& dc, const TextStyle& style) const {
|
||||||
RealSize line_size(line.margin_left + lineLeft(dc, style, line.top), 0);
|
RealSize line_size(line.margin_left + lineLeft(dc, style, line.top), 0);
|
||||||
while (line.top < style.height && line_size.width + 1 >= style.width - style.padding_right - line.margin_right) {
|
while (line.top < dc.getHeight() && line_size.width + 1 >= dc.getWidth() - style.padding_right - line.margin_right) {
|
||||||
// nothing fits on this line, move down one pixel
|
// nothing fits on this line, move down one pixel
|
||||||
line.top += 1;
|
line.top += 1;
|
||||||
line_size.width = line.margin_left + lineLeft(dc, style, line.top);
|
line_size.width = line.margin_left + lineLeft(dc, style, line.top);
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ void ColorValueViewer::draw(RotatedDC& dc) {
|
|||||||
style().top_width < style().height && style().bottom_width < style().height;
|
style().top_width < style().height && style().bottom_width < style().height;
|
||||||
if (clip) {
|
if (clip) {
|
||||||
// clip away the inside of the rectangle
|
// clip away the inside of the rectangle
|
||||||
wxRegion r = dc.trRectToRegion(style().getInternalRect());
|
wxRegion r = dc.trRectToRegion(dc.getInternalRect());
|
||||||
r.Subtract(dc.trRectToRegion(RealRect(
|
r.Subtract(dc.trRectToRegion(RealRect(
|
||||||
style().left_width,
|
style().left_width,
|
||||||
style().top_width,
|
style().top_width,
|
||||||
@@ -59,7 +59,7 @@ void ColorValueViewer::draw(RotatedDC& dc) {
|
|||||||
)));
|
)));
|
||||||
dc.getDC().SetClippingRegion(r);
|
dc.getDC().SetClippingRegion(r);
|
||||||
}
|
}
|
||||||
dc.DrawRoundedRectangle(style().getInternalRect(), style().radius);
|
dc.DrawRoundedRectangle(dc.getInternalRect(), style().radius);
|
||||||
if (clip) dc.getDC().DestroyClippingRegion();
|
if (clip) dc.getDC().DestroyClippingRegion();
|
||||||
}
|
}
|
||||||
drawFieldBorder(dc);
|
drawFieldBorder(dc);
|
||||||
@@ -69,15 +69,15 @@ void ColorValueViewer::draw(RotatedDC& dc) {
|
|||||||
bool ColorValueViewer::containsPoint(const RealPoint& p) const {
|
bool ColorValueViewer::containsPoint(const RealPoint& p) const {
|
||||||
// check against mask
|
// check against mask
|
||||||
const AlphaMask& alpha_mask = getMask();
|
const AlphaMask& alpha_mask = getMask();
|
||||||
if (alpha_mask.isLoaded()) {
|
if (alpha_mask.isLoaded() || nativeLook()) {
|
||||||
// check against mask
|
// check against mask
|
||||||
return alpha_mask.isOpaque(p, style().getSize());
|
return alpha_mask.isOpaque(p, bounding_box.size());
|
||||||
} else {
|
} else {
|
||||||
double left = p.x, right = style().width - p.x - 1;
|
double left = p.x, right = style().width - p.x - 1;
|
||||||
double top = p.y, bottom = style().height - p.y - 1;
|
double top = p.y, bottom = style().height - p.y - 1;
|
||||||
if (left < 0 || right < 0 || top < 0 || bottom < 0) return false; // outside bounding box
|
if (left < 0 || right < 0 || top < 0 || bottom < 0) return false; // outside bounding box
|
||||||
// check against border
|
// check against border
|
||||||
return left < style().left_width || right < style().right_width // inside horizontal border
|
return left < style().left_width || right < style().right_width // inside horizontal border
|
||||||
|| top < style().top_width || bottom < style().bottom_width; // inside vertical border
|
|| top < style().top_width || bottom < style().bottom_width; // inside vertical border
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ void InfoValueViewer::draw(RotatedDC& dc) {
|
|||||||
dc.SetFont(style().font, 1.0);
|
dc.SetFont(style().font, 1.0);
|
||||||
}
|
}
|
||||||
// draw background
|
// draw background
|
||||||
RealRect rect = style().getInternalRect();
|
RealRect rect = dc.getInternalRect();
|
||||||
dc.DrawRectangle(rect.grow(2));
|
dc.DrawRectangle(rect.grow(2));
|
||||||
// draw text
|
// draw text
|
||||||
rect = rect.move(
|
rect = rect.move(
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ bool MultipleChoiceValueViewer::prepare(RotatedDC& dc) {
|
|||||||
void MultipleChoiceValueViewer::draw(RotatedDC& dc) {
|
void MultipleChoiceValueViewer::draw(RotatedDC& dc) {
|
||||||
drawFieldBorder(dc);
|
drawFieldBorder(dc);
|
||||||
if (style().render_style & RENDER_HIDDEN) return;
|
if (style().render_style & RENDER_HIDDEN) return;
|
||||||
RealPoint pos = align_in_rect(style().alignment, RealSize(0,0), style().getInternalRect());
|
RealPoint pos = align_in_rect(style().alignment, RealSize(0,0), dc.getInternalRect());
|
||||||
// selected choices
|
// selected choices
|
||||||
vector<String> selected;
|
vector<String> selected;
|
||||||
value().get(selected);
|
value().get(selected);
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ IMPLEMENT_VALUE_VIEWER(Symbol);
|
|||||||
void SymbolValueViewer::draw(RotatedDC& dc) {
|
void SymbolValueViewer::draw(RotatedDC& dc) {
|
||||||
drawFieldBorder(dc);
|
drawFieldBorder(dc);
|
||||||
// draw checker background
|
// draw checker background
|
||||||
draw_checker(dc, style().getInternalRect());
|
draw_checker(dc, dc.getInternalRect());
|
||||||
double wh = min(dc.getWidth(), dc.getHeight());
|
double wh = min(dc.getWidth(), dc.getHeight());
|
||||||
// try to load symbol
|
// try to load symbol
|
||||||
if (symbols.empty() && !value().filename.empty()) {
|
if (symbols.empty() && !value().filename.empty()) {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
ValueViewer::ValueViewer(DataViewer& parent, const StyleP& style)
|
ValueViewer::ValueViewer(DataViewer& parent, const StyleP& style)
|
||||||
: StyleListener(style), parent(parent)
|
: StyleListener(style), parent(parent)
|
||||||
|
, bounding_box(style->getExternalRect())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Package& ValueViewer::getStylePackage() const { return parent.getStylePackage(); }
|
Package& ValueViewer::getStylePackage() const { return parent.getStylePackage(); }
|
||||||
@@ -27,14 +28,21 @@ void ValueViewer::setValue(const ValueP& value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ValueViewer::containsPoint(const RealPoint& p) const {
|
bool ValueViewer::containsPoint(const RealPoint& p) const {
|
||||||
return getMask().isOpaque(p, styleP->getSize());
|
return getMask().isOpaque(p, bounding_box.size());
|
||||||
}
|
}
|
||||||
RealRect ValueViewer::boundingBox() const {
|
RealRect ValueViewer::boundingBoxBorder() const {
|
||||||
return styleP->getExternalRect().grow(1);
|
return bounding_box.grow(1);
|
||||||
|
}
|
||||||
|
bool ValueViewer::isVisible() const {
|
||||||
|
return getStyle()->visible
|
||||||
|
&& bounding_box.width > 0
|
||||||
|
&& bounding_box.height > 0
|
||||||
|
&& fabs(bounding_box.x) < 100000
|
||||||
|
&& fabs(bounding_box.y) < 100000;
|
||||||
}
|
}
|
||||||
|
|
||||||
Rotation ValueViewer::getRotation() const {
|
Rotation ValueViewer::getRotation() const {
|
||||||
return Rotation(deg_to_rad(getStyle()->angle), getStyle()->getExternalRect(), 1.0, getStretch());
|
return Rotation(deg_to_rad(getStyle()->angle), bounding_box, 1.0, getStretch());
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__WXMSW__)
|
#if defined(__WXMSW__)
|
||||||
@@ -113,4 +121,6 @@ void ValueViewer::onStyleChange(int changes) {
|
|||||||
if (!(changes & CHANGE_ALREADY_PREPARED)) {
|
if (!(changes & CHANGE_ALREADY_PREPARED)) {
|
||||||
parent.redraw(*this);
|
parent.redraw(*this);
|
||||||
}
|
}
|
||||||
|
// update bounding box
|
||||||
|
if (!nativeLook()) bounding_box = getStyle()->getExternalRect();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,9 @@ public:
|
|||||||
/// Does this field contian the given point?
|
/// Does this field contian the given point?
|
||||||
virtual bool containsPoint(const RealPoint& p) const;
|
virtual bool containsPoint(const RealPoint& p) const;
|
||||||
/// Get a bounding rectangle for this field (including any border it may have)
|
/// Get a bounding rectangle for this field (including any border it may have)
|
||||||
virtual RealRect boundingBox() const;
|
virtual RealRect boundingBoxBorder() const;
|
||||||
|
/// Is this field visible?
|
||||||
|
bool isVisible() const;
|
||||||
|
|
||||||
/// Rotation to use for drawing this field
|
/// Rotation to use for drawing this field
|
||||||
virtual Rotation getRotation() const;
|
virtual Rotation getRotation() const;
|
||||||
@@ -73,6 +75,7 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
DataViewer& parent; ///< Our parent object
|
DataViewer& parent; ///< Our parent object
|
||||||
|
RealRect bounding_box; ///< The bounding box of this viewer. Corresponds to styleP->getExternalRect(), except for native look editor
|
||||||
protected:
|
protected:
|
||||||
ValueP valueP; ///< The value we are currently viewing
|
ValueP valueP; ///< The value we are currently viewing
|
||||||
|
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ public:
|
|||||||
inline RealPoint bottomRight() const { return RealPoint(x + width, y + height); }
|
inline RealPoint bottomRight() const { return RealPoint(x + width, y + height); }
|
||||||
|
|
||||||
/// Return a rectangle that is amount larger to all sides
|
/// Return a rectangle that is amount larger to all sides
|
||||||
inline RealRect grow(double amount) {
|
inline RealRect grow(double amount) const {
|
||||||
return RealRect(x - amount, y - amount, width + 2 * amount, height + 2 * amount);
|
return RealRect(x - amount, y - amount, width + 2 * amount, height + 2 * amount);
|
||||||
}
|
}
|
||||||
/// Move the coordinates by some amount
|
/// Move the coordinates by some amount
|
||||||
|
|||||||
Reference in New Issue
Block a user