summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2011-11-18 20:39:40 +0000
committerfrosch <frosch@openttd.org>2011-11-18 20:39:40 +0000
commit100971630d2427a4e54db4f5602231b00b2d08d6 (patch)
tree2613803b214866e976b68099ce0fb079a4e852c4
parentca4f0509fcd828711fcf799222b3ac27360d91bc (diff)
downloadopenttd-100971630d2427a4e54db4f5602231b00b2d08d6.tar.xz
(svn r23253) -Fix: Several clipping issues with the display of textfiles, esp. with RTL text direction.
-rw-r--r--src/newgrf_gui.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp
index 1e8309e21..b4bc177d1 100644
--- a/src/newgrf_gui.cpp
+++ b/src/newgrf_gui.cpp
@@ -524,14 +524,22 @@ struct NewGRFTextfileWindow : public Window {
{
if (widget != GTW_WIDGET_BACKGROUND) return;
- DrawPixelInfo new_dpi;
- if (!FillDrawPixelInfo(&new_dpi, r.left, r.top, r.right - r.left + 1, r.bottom - r.top + 1)) return;
+ int width = r.right - r.left + 1 - WD_BEVEL_LEFT - WD_BEVEL_RIGHT;
+ int height = r.bottom - r.top + 1 - WD_BEVEL_LEFT - WD_BEVEL_RIGHT;
+ DrawPixelInfo new_dpi;
+ if (!FillDrawPixelInfo(&new_dpi, r.left + WD_BEVEL_LEFT, r.top, width, height)) return;
DrawPixelInfo *old_dpi = _cur_dpi;
_cur_dpi = &new_dpi;
- int left = WD_FRAMETEXT_LEFT - this->hscroll->GetPosition();
- int right = r.right - r.left - WD_FRAMETEXT_LEFT - WD_FRAMETEXT_RIGHT;
+ int left, right;
+ if (_current_text_dir == TD_RTL) {
+ left = width + WD_BEVEL_RIGHT - WD_FRAMETEXT_RIGHT - this->hscroll->GetCount();
+ right = width + WD_BEVEL_RIGHT - WD_FRAMETEXT_RIGHT - 1 + this->hscroll->GetPosition();
+ } else {
+ left = WD_FRAMETEXT_LEFT - WD_BEVEL_LEFT - this->hscroll->GetPosition();
+ right = WD_FRAMETEXT_LEFT - WD_BEVEL_LEFT + this->hscroll->GetCount() - 1;
+ }
int top = TOP_SPACING;
for (uint i = 0; i < this->vscroll->GetCapacity() && i + this->vscroll->GetPosition() < this->lines.Length(); i++) {
DrawString(left, right, top + i * this->line_height, this->lines[i + this->vscroll->GetPosition()], TC_WHITE);
@@ -542,7 +550,7 @@ struct NewGRFTextfileWindow : public Window {
virtual void OnResize()
{
- this->vscroll->SetCapacityFromWidget(this, GTW_WIDGET_BACKGROUND, this->line_height);
+ this->vscroll->SetCapacityFromWidget(this, GTW_WIDGET_BACKGROUND, TOP_SPACING + BOTTOM_SPACING);
this->hscroll->SetCapacityFromWidget(this, GTW_WIDGET_BACKGROUND);
}