mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 05:07:00 -04:00
Allow ValueViewers to have a bounding box different from the Style's. This closes #64.
This commit is contained in:
@@ -275,11 +275,11 @@ void ChoiceValueEditor::onLoseFocus() {
|
||||
void ChoiceValueEditor::draw(RotatedDC& dc) {
|
||||
ChoiceValueViewer::draw(dc);
|
||||
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) {
|
||||
style().height = max(style().height(), 16.);
|
||||
bounding_box.height = max(bounding_box.height, 16.);
|
||||
}
|
||||
|
||||
void ChoiceValueEditor::change(const Defaultable<String>& c) {
|
||||
|
||||
@@ -148,7 +148,7 @@ void ColorValueEditor::draw(RotatedDC& dc) {
|
||||
}
|
||||
}
|
||||
void ColorValueEditor::determineSize(bool) {
|
||||
style().height = 20;
|
||||
bounding_box.height = 20;
|
||||
}
|
||||
|
||||
void ColorValueEditor::change(const Defaultable<Color>& c) {
|
||||
|
||||
@@ -14,5 +14,5 @@
|
||||
IMPLEMENT_VALUE_EDITOR(Info) {}
|
||||
|
||||
void InfoValueEditor::determineSize(bool) {
|
||||
style().height = 26;
|
||||
bounding_box.height = 26;
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ void MultipleChoiceValueEditor::determineSize(bool force_fit) {
|
||||
item_height = 18;
|
||||
// height depends on number of items and item height
|
||||
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) {
|
||||
|
||||
@@ -101,11 +101,11 @@ void PackageChoiceValueEditor::onLoseFocus() {
|
||||
void PackageChoiceValueEditor::draw(RotatedDC& dc) {
|
||||
PackageChoiceValueViewer::draw(dc);
|
||||
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) {
|
||||
style().height = max(style().height(), 16.);
|
||||
bounding_box.height = max(bounding_box.height, 16.);
|
||||
}
|
||||
|
||||
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.SetTextForeground(*wxBLACK);
|
||||
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()) {
|
||||
// draw editor buttons
|
||||
@@ -38,9 +38,9 @@ void SymbolValueEditor::draw(RotatedDC& dc) {
|
||||
}
|
||||
void SymbolValueEditor::drawButton(RotatedDC& dc, int button, const String& text) {
|
||||
bool down = button == button_down;
|
||||
double height = style().height;
|
||||
double width = style().height + 2;
|
||||
double x = style().width - width - (width + 1) * button;
|
||||
double height = bounding_box.height;
|
||||
double width = bounding_box.height + 2;
|
||||
double x = bounding_box.width - width - (width + 1) * button;
|
||||
double y = 0;
|
||||
// draw button
|
||||
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) {
|
||||
if (pos.y < 0 || pos.y >= style().height) return -1;
|
||||
int button = (int)floor( (style().width - pos.x) / (style().height + 3) );
|
||||
if (pos.y < 0 || pos.y >= bounding_box.height) return -1;
|
||||
int button = (int)floor( (bounding_box.width - pos.x) / (bounding_box.height + 3) );
|
||||
if (button >= 0 && button <= 1) return button;
|
||||
return -1;
|
||||
}
|
||||
@@ -107,7 +107,8 @@ bool SymbolValueEditor::onLeftDClick(const RealPoint& pos, wxMouseEvent&) {
|
||||
}
|
||||
|
||||
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) {
|
||||
if (nativeLook()) {
|
||||
// clip the dc to the region of this control
|
||||
dc.SetClippingRegion(style().getInternalRect());
|
||||
dc.SetClippingRegion(dc.getInternalRect());
|
||||
}
|
||||
// update scrollbar
|
||||
prepareDrawScrollbar(dc);
|
||||
@@ -663,7 +663,7 @@ void TextValueEditor::redrawSelection(size_t old_selection_start_i, size_t old_s
|
||||
Rotater r(dc, getRotation());
|
||||
if (nativeLook()) {
|
||||
// clip the dc to the region of this control
|
||||
dc.SetClippingRegion(style().getInternalRect());
|
||||
dc.SetClippingRegion(dc.getInternalRect());
|
||||
}
|
||||
// clear old selection by drawing it again
|
||||
if (!old_drop_down_shown) {
|
||||
@@ -727,9 +727,8 @@ bool TextValueEditor::containsPoint(const RealPoint& pos) const {
|
||||
if (word_lists.empty()) return false;
|
||||
return (bool) findWordList(pos);
|
||||
}
|
||||
RealRect TextValueEditor::boundingBox() const {
|
||||
if (word_lists.empty()) return ValueViewer::boundingBox();
|
||||
RealRect r = style().getInternalRect().grow(1);
|
||||
RealRect TextValueEditor::boundingBoxBorder() const {
|
||||
RealRect r = ValueViewer::boundingBoxBorder();
|
||||
FOR_EACH_CONST(wl, word_lists) {
|
||||
r.width = max(r.width, wl->rect.right() + 9);
|
||||
}
|
||||
@@ -1255,14 +1254,16 @@ void TextValueEditor::determineSize(bool force_fit) {
|
||||
// muliline, determine scrollbar size
|
||||
Rotation rot = parent.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);
|
||||
RealPoint pos = rot.tr(RealPoint(0,0));
|
||||
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)sbw,
|
||||
(int)rot.trY(style().height) + 2);
|
||||
(int)rot.trY(bounding_box.height) + 2);
|
||||
v.reset(true);
|
||||
} else {
|
||||
// Height depends on font
|
||||
@@ -1272,6 +1273,7 @@ void TextValueEditor::determineSize(bool force_fit) {
|
||||
dc.SetFont(style().font.toWxFont(1.0));
|
||||
style().height = dc.GetCharHeight() + 2 + style().padding_top + style().padding_bottom;
|
||||
}
|
||||
bounding_box.height = style().height;
|
||||
}
|
||||
|
||||
void TextValueEditor::onShow(bool showing) {
|
||||
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
wxCursor cursor(const RealPoint& pos) const override;
|
||||
void determineSize(bool force_fit = false) override;
|
||||
bool containsPoint(const RealPoint& p) const override;
|
||||
RealRect boundingBox() const override;
|
||||
RealRect boundingBoxBorder() const override;
|
||||
void onShow(bool) override;
|
||||
void draw(RotatedDC&) override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user