Changeset - r18407:19e3cae147c4
[Not reviewed]
master
0 1 0
frosch - 13 years ago 2011-11-18 20:39:40
frosch@openttd.org
(svn r23253) -Fix: Several clipping issues with the display of textfiles, esp. with RTL text direction.
1 file changed with 13 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/newgrf_gui.cpp
Show inline comments
 
@@ -524,14 +524,22 @@ struct NewGRFTextfileWindow : public Win
 
	{
 
		if (widget != GTW_WIDGET_BACKGROUND) 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, r.top, r.right - r.left + 1, r.bottom - r.top + 1)) return;
 

	
 
		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 Win
 

	
 
	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);
 
	}
 

	
0 comments (0 inline, 0 general)