1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-21 21:49:10 +00:00

Codechange: use RAII to automatically restore _cur_dpi after use

This commit is contained in:
Rubidium
2023-01-26 19:21:36 +01:00
committed by rubidium42
parent b7a5d8e296
commit f001e84e5e
18 changed files with 122 additions and 136 deletions

View File

@@ -8,6 +8,7 @@
/** @file textfile_gui.cpp Implementation of textfile window. */
#include "stdafx.h"
#include "core/backup_type.hpp"
#include "fileio_func.h"
#include "fontcache.h"
#include "gfx_type.h"
@@ -152,8 +153,7 @@ void TextfileWindow::SetupScrollbars(bool force_reflow)
DrawPixelInfo new_dpi;
if (!FillDrawPixelInfo(&new_dpi, fr.left, fr.top, fr.Width(), fr.Height())) return;
DrawPixelInfo *old_dpi = _cur_dpi;
_cur_dpi = &new_dpi;
AutoRestoreBackup dpi_backup(_cur_dpi, &new_dpi);
/* Draw content (now coordinates given to DrawString* are local to the new clipping region). */
fr = fr.Translate(-fr.left, -fr.top);
@@ -172,8 +172,6 @@ void TextfileWindow::SetupScrollbars(bool force_reflow)
DrawString(-this->hscroll->GetPosition(), fr.right, y_offset, line.text, TC_BLACK, SA_TOP | SA_LEFT, false, FS_MONO);
}
}
_cur_dpi = old_dpi;
}
/* virtual */ void TextfileWindow::OnResize()