From 60ee9553d4b0a086922d526eaf0d017d1ea3b86b Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Wed, 14 Jan 2009 15:23:07 +0000 Subject: [PATCH] made some of the font-properties class members instead of const variables (and even worse, global variables). --- editor/trackview.cpp | 22 ++++++++++++++++------ editor/trackview.h | 7 +++++++ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/editor/trackview.cpp b/editor/trackview.cpp index 8850002..848256e 100644 --- a/editor/trackview.cpp +++ b/editor/trackview.cpp @@ -10,15 +10,20 @@ static const TCHAR *trackViewWindowClassName = _T("TrackView"); static const int topMarginHeight = 20; static const int leftMarginWidth = 60; -static int rowHeight = 16; -static int fontWidth = 6; - -static const int trackWidth = fontWidth * 16; static DWORD darken(DWORD col, float amt) { return RGB(GetRValue(col) * amt, GetGValue(col) * amt, GetBValue(col) * amt); } +void TrackView::setFont(HFONT font) +{ + this->font = font; + + rowHeight = 16; + fontWidth = 6; + trackWidth = fontWidth * 16; +} + TrackView::TrackView() { IniFile::load("rocket.ini", "GUI"); @@ -44,6 +49,11 @@ TrackView::TrackView() this->hwnd = NULL; +// setFont((HFONT)GetStockObject(SYSTEM_FONT)); + setFont((HFONT)GetStockObject(SYSTEM_FIXED_FONT)); +// font = (HFONT)GetStockObject(SYSTEM_FONT); +// font = (HFONT)GetStockObject(SYSTEM_FIXED_FONT); + bgBaseBrush = GetSysColorBrush(COLOR_WINDOW); bgDarkBrush = CreateSolidBrush(darken(GetSysColor(COLOR_WINDOW), 0.9f)); @@ -98,8 +108,8 @@ LRESULT TrackView::onPaint() PAINTSTRUCT ps; HDC hdc = BeginPaint(hwnd, &ps); - SelectObject(hdc, GetStockObject(SYSTEM_FIXED_FONT)); -// SelectObject(hdc, GetStockObject(SYSTEM_FONT)); +// SelectObject(hdc, GetStockObject(SYSTEM_FIXED_FONT)); + SelectObject(hdc, font); paintTracks(hdc, ps.rcPaint); EndPaint(hwnd, &ps); diff --git a/editor/trackview.h b/editor/trackview.h index cbc3b1e..905f905 100644 --- a/editor/trackview.h +++ b/editor/trackview.h @@ -32,6 +32,8 @@ public: if (NULL == document) return 0; return document->getRows(); } + + void setFont(HFONT font); void editEnterValue(); void editDelete(); @@ -149,6 +151,11 @@ private: int selectStartTrack, selectStopTrack; int selectStartRow, selectStopRow; + HFONT font; + int rowHeight; + int fontWidth; + int trackWidth; + HBRUSH bgBaseBrush, bgDarkBrush; HBRUSH selectBaseBrush, selectDarkBrush; HPEN rowPen, rowSelectPen;