From 9ab052d0edafb2c9a5f4a532efa94e5b305552c0 Mon Sep 17 00:00:00 2001
From: ElzorFox <elzorfox@ya.ru>
Date: Sun, 28 Apr 2024 15:04:43 +0500
Subject: NewStory: scroll 3 textline on MOUSEWHEEL (Windows default) set
 textline height as font FONT_INMSG height

---
 plugins/NewStory/src/history_control.cpp | 14 ++++++++------
 plugins/NewStory/src/history_control.h   |  5 +++--
 2 files changed, 11 insertions(+), 8 deletions(-)

(limited to 'plugins/NewStory/src')

diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp
index d4da49277d..a3ea867b5b 100644
--- a/plugins/NewStory/src/history_control.cpp
+++ b/plugins/NewStory/src/history_control.cpp
@@ -63,6 +63,8 @@ NewstoryListData::NewstoryListData(HWND _1) :
 	bSortAscending = g_plugin.bSortAscending;
 
 	redrawTimer.OnEvent = Callback(this, &NewstoryListData::onTimer_Draw);
+
+	iLineHeigth = GetFontHeight(g_fontTable[FONT_INMSG].lf);
 }
 
 void NewstoryListData::onTimer_Draw(CTimer *pTimer)
@@ -992,18 +994,18 @@ void NewstoryListData::TryUp(int iCount)
 /////////////////////////////////////////////////////////////////////////////////////////
 // Navigation by coordinates
 
-void NewstoryListData::LineUp()
+void NewstoryListData::LineUp(int iCount)
 {
 	if (AtTop())
 		TryUp(1);
 	else
-		ScrollUp(10);
+		ScrollUp(iLineHeigth * iCount);
 }
 
-void NewstoryListData::LineDown()
+void NewstoryListData::LineDown(int iCount)
 {
 	if (!AtBottom())
-		ScrollDown(10);
+		ScrollDown(iLineHeigth * iCount);
 }
 
 void NewstoryListData::PageUp()
@@ -1473,9 +1475,9 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
 
 	case WM_MOUSEWHEEL:
 		if ((short)HIWORD(wParam) < 0)
-			data->LineDown();
+			data->LineDown(3);
 		else
-			data->LineUp();
+			data->LineUp(3);
 		return TRUE;
 
 	case WM_VSCROLL:
diff --git a/plugins/NewStory/src/history_control.h b/plugins/NewStory/src/history_control.h
index 0a679ff00b..afdaa7e67e 100644
--- a/plugins/NewStory/src/history_control.h
+++ b/plugins/NewStory/src/history_control.h
@@ -107,6 +107,7 @@ struct NewstoryListData : public MZeroedObject
 	int cachedMaxDrawnItem = -1;
 	int cachedScrollbarPos = -1, cachedScrollbarMax = -1;
 	int totalCount;
+	int iLineHeigth;
 
 	RECT rcLastPaint;
 	MCONTACT m_hContact = INVALID_CONTACT_ID;
@@ -159,8 +160,8 @@ struct NewstoryListData : public MZeroedObject
 	int       GetItemHeight(ItemData *pItem);
 	bool      HasSelection() const;
 	void      HitTotal(int yCurr, int yTotal);
-	void      LineUp();
-	void      LineDown();
+	void      LineUp(int iCount = 1);
+	void      LineDown(int iCount = 1);
 	ItemData* LoadItem(int idx);
 	void      MarkRead(ItemData *pItem);
 	void      OpenFolder();
-- 
cgit v1.2.3