Fix height of multi line text boxes and TextCtrls

This commit is contained in:
Twan van Laarhoven
2020-06-01 13:33:53 +02:00
parent 989da67ec3
commit 36c1c2541a
2 changed files with 9 additions and 10 deletions
+2 -2
View File
@@ -123,8 +123,8 @@ wxSize TextCtrl::DoGetBestSize() const {
return wxSize(1,1); return wxSize(1,1);
} else { } else {
wxSize ws = GetSize(), cs = GetClientSize(); wxSize ws = GetSize(), cs = GetClientSize();
Style& style = *viewers.front()->getStyle(); ValueViewer& viewer = *viewers.front();
return wxSize(style.width, style.height) + ws - cs; return wxSize(viewer.bounding_box.width, viewer.bounding_box.height) + ws - cs;
} }
} }
+7 -8
View File
@@ -899,7 +899,7 @@ void TextValueEditor::showCaret() {
} }
// clip caret pos and size; show caret // clip caret pos and size; show caret
if (nativeLook()) { if (nativeLook()) {
if (cursor.y + cursor.height <= 0 || cursor.y >= style().height) { if (cursor.y + cursor.height <= 0 || cursor.y >= bounding_box.height) {
// caret should be hidden // caret should be hidden
if (caret->IsVisible()) caret->Hide(); if (caret->IsVisible()) caret->Hide();
return; return;
@@ -907,9 +907,9 @@ void TextValueEditor::showCaret() {
// caret partially hidden, clip // caret partially hidden, clip
cursor.height -= -cursor.y; cursor.height -= -cursor.y;
cursor.y = 0; cursor.y = 0;
} else if (cursor.y + cursor.height >= style().height) { } else if (cursor.y + cursor.height >= bounding_box.height) {
// caret partially hidden, clip // caret partially hidden, clip
cursor.height = style().height - cursor.y; cursor.height = bounding_box.height - cursor.y;
} }
} }
// rotate // rotate
@@ -1255,7 +1255,7 @@ void TextValueEditor::determineSize(bool force_fit) {
Rotation rot = parent.getRotation(); Rotation rot = parent.getRotation();
Rotater r(rot, getRotation()); Rotater r(rot, getRotation());
if (!force_fit) { if (!force_fit) {
style().height = bounding_box.height = 100; 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));
@@ -1271,9 +1271,8 @@ void TextValueEditor::determineSize(bool force_fit) {
Bitmap bmp(1,1); Bitmap bmp(1,1);
dc.SelectObject(bmp); dc.SelectObject(bmp);
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; bounding_box.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) {
@@ -1305,7 +1304,7 @@ void TextValueEditor::scrollTo(int pos) {
bool TextValueEditor::ensureCaretVisible() { bool TextValueEditor::ensureCaretVisible() {
if (scrollbar && scroll_with_cursor) { if (scrollbar && scroll_with_cursor) {
scroll_with_cursor = false; scroll_with_cursor = false;
return v.ensureVisible(style().height - style().padding_top - style().padding_bottom, selection_end_i); return v.ensureVisible(bounding_box.height - style().padding_top - style().padding_bottom, selection_end_i);
} }
return false; return false;
} }
@@ -1313,7 +1312,7 @@ bool TextValueEditor::ensureCaretVisible() {
void TextValueEditor::updateScrollbar() { void TextValueEditor::updateScrollbar() {
assert(scrollbar); assert(scrollbar);
int position = (int)v.firstVisibleLine(); int position = (int)v.firstVisibleLine();
int page_size = (int)v.visibleLineCount(style().height - style().padding_top - style().padding_bottom); int page_size = (int)v.visibleLineCount(bounding_box.height - style().padding_top - style().padding_bottom);
int range = (int)v.lineCount(); int range = (int)v.lineCount();
scrollbar->SetScrollbar( scrollbar->SetScrollbar(
wxVERTICAL, wxVERTICAL,