summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/NewStory/res/resource.rc26
-rw-r--r--plugins/NewStory/src/history_control.cpp117
-rw-r--r--plugins/NewStory/src/history_control.h52
-rw-r--r--plugins/NewStory/src/history_dlg.cpp29
4 files changed, 131 insertions, 93 deletions
diff --git a/plugins/NewStory/res/resource.rc b/plugins/NewStory/res/resource.rc
index 2fd6cfba4d..b12365f44c 100644
--- a/plugins/NewStory/res/resource.rc
+++ b/plugins/NewStory/res/resource.rc
@@ -79,22 +79,22 @@ IDD_HISTORY DIALOGEX 0, 0, 380, 319
STYLE DS_SETFONT | DS_NOIDLEMSG | DS_CENTER | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
- CONTROL "",IDC_USERINFO,"MButtonClass",WS_TABSTOP,0,99,16,14
- CONTROL "",IDC_USERMENU,"MButtonClass",WS_TABSTOP,21,99,16,14
- CONTROL "",IDC_MESSAGE,"MButtonClass",WS_TABSTOP,37,99,16,14
- CONTROL "",IDC_SEARCH,"MButtonClass",WS_TABSTOP,53,99,16,14
- CONTROL "",IDC_COPY,"MButtonClass",WS_TABSTOP,74,99,16,14
- CONTROL "",IDC_EXPORT,"MButtonClass",WS_TABSTOP,90,99,16,14
- CONTROL "",IDC_DELETE,"MButtonClass",WS_TABSTOP,104,99,16,14
- CONTROL "",IDC_TIMETREE,"MButtonClass",WS_TABSTOP,118,99,16,14
- CONTROL "",IDC_FILTER,"MButtonClass",WS_TABSTOP,132,99,16,14
- CONTROL "",IDC_FINDPREV,"MButtonClass",WS_TABSTOP,364,305,16,14
- CONTROL "",IDOK,"MButtonClass",WS_TABSTOP,337,305,16,14
+ CONTROL "",IDC_USERINFO,"MButtonClass",NOT WS_TABSTOP,0,99,16,14
+ CONTROL "",IDC_USERMENU,"MButtonClass",NOT WS_TABSTOP,21,99,16,14
+ CONTROL "",IDC_MESSAGE,"MButtonClass",NOT WS_TABSTOP,37,99,16,14
+ CONTROL "",IDC_SEARCH,"MButtonClass",NOT WS_TABSTOP,53,99,16,14
+ CONTROL "",IDC_COPY,"MButtonClass",NOT WS_TABSTOP,74,99,16,14
+ CONTROL "",IDC_EXPORT,"MButtonClass",NOT WS_TABSTOP,90,99,16,14
+ CONTROL "",IDC_DELETE,"MButtonClass",NOT WS_TABSTOP,104,99,16,14
+ CONTROL "",IDC_TIMETREE,"MButtonClass",NOT WS_TABSTOP,118,99,16,14
+ CONTROL "",IDC_FILTER,"MButtonClass",NOT WS_TABSTOP,132,99,16,14
+ CONTROL "",IDC_FINDPREV,"MButtonClass",NOT WS_TABSTOP,364,305,16,14
+ CONTROL "",IDOK,"MButtonClass",NOT WS_TABSTOP,337,305,16,14
EDITTEXT IDC_SEARCHTEXT,19,305,305,14,ES_AUTOHSCROLL
ICON "",IDC_SEARCHICON,1,298,20,20,SS_CENTERIMAGE
- CONTROL "",IDC_LOGOPTIONS,"MButtonClass",WS_TABSTOP,116,99,16,14
+ CONTROL "",IDC_LOGOPTIONS,"MButtonClass",NOT WS_TABSTOP,116,99,16,14
CONTROL "",IDC_TIMETREEVIEW,"SysTreeView32",TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_DISABLEDRAGDROP | TVS_SHOWSELALWAYS | TVS_TRACKSELECT | TVS_FULLROWSELECT | TVS_SINGLEEXPAND | NOT WS_VISIBLE | WS_TABSTOP,0,134,84,160,WS_EX_STATICEDGE
- CONTROL "",IDC_DATEPOPUP,"MButtonClass",WS_TABSTOP,148,99,16,14
+ CONTROL "",IDC_DATEPOPUP,"MButtonClass",NOT WS_TABSTOP,148,99,16,14
CONTROL "",IDC_HISTORYCONTROL,"NewstoryList",WS_TABSTOP,90,132,290,166
CONTROL "",IDC_IB_SEPARATOR,"Static",SS_ETCHEDHORZ,21,76,124,1
ICON "",IDC_ICO_MESSAGES,4,7,20,20
diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp
index b4e82e77a1..3e78830322 100644
--- a/plugins/NewStory/src/history_control.cpp
+++ b/plugins/NewStory/src/history_control.cpp
@@ -31,7 +31,7 @@ void InitHotkeys()
g_plugin.addHotkey(&hkd);
}
-/////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////
// Control utilities, types and constants
NewstoryListData::NewstoryListData(HWND _1) :
@@ -215,6 +215,7 @@ void NewstoryListData::EnsureVisible(int item)
if (scrollTopItem >= item) {
scrollTopItem = item;
scrollTopPixel = 0;
+ InvalidateRect(hwnd, 0, FALSE);
}
else {
RECT rc;
@@ -237,6 +238,7 @@ void NewstoryListData::EnsureVisible(int item)
if (!found) {
scrollTopItem = item;
scrollTopPixel = 0;
+ InvalidateRect(hwnd, 0, FALSE);
}
}
FixScrollPosition();
@@ -268,9 +270,6 @@ void NewstoryListData::FixScrollPosition()
scrollTopItem = cachedMaxTopItem;
scrollTopPixel = cachedMaxTopPixel;
}
-
- if (g_plugin.bOptVScroll)
- RecalcScrollBar();
}
ItemData* NewstoryListData::GetItem(int idx)
@@ -333,7 +332,7 @@ int NewstoryListData::GetItemHeight(int index)
return item->savedHeight = sz.cy + 5;
}
-ItemData *NewstoryListData::LoadItem(int idx)
+ItemData* NewstoryListData::LoadItem(int idx)
{
if (totalCount == 0)
return nullptr;
@@ -406,9 +405,14 @@ void NewstoryListData::RecalcScrollBar()
si.fMask = SIF_ALL;
si.nMin = 0;
si.nMax = totalCount-1;
- si.nPage = si.nMax / 10;
- si.nPos = caret;
- SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
+ si.nPage = cachedMaxDrawnItem - scrollTopItem;
+ si.nPos = scrollTopItem;
+
+ if (cachedScrollbarPage != si.nPage || si.nPos != cachedScrollbarPos) {
+ cachedScrollbarPos = si.nPos;
+ cachedScrollbarPage = si.nPage;
+ SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
+ }
}
void NewstoryListData::ScheduleDraw()
@@ -428,9 +432,8 @@ void NewstoryListData::SetCaret(int idx, bool bEnsureVisible)
void NewstoryListData::SetPos(int pos)
{
- caret = pos;
SetSelection((selStart == -1) ? pos : selStart, pos);
- SetCaret(pos, true);
+ SetCaret(pos);
}
void NewstoryListData::SetSelection(int iFirst, int iLast)
@@ -481,7 +484,72 @@ void NewstoryListData::ToggleSelection(int iFirst, int iLast)
InvalidateRect(hwnd, 0, FALSE);
}
-/////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////
+// Navigation
+
+void NewstoryListData::LineUp()
+{
+ if (scrollTopItem <= 0)
+ return;
+
+ if (scrollTopPixel == 0)
+ scrollTopItem--;
+ else {
+ cachedMaxTopItem = -1;
+ scrollTopPixel = 0;
+ }
+ FixScrollPosition();
+ InvalidateRect(hwnd, 0, FALSE);
+}
+
+void NewstoryListData::LineDown()
+{
+ if (cachedMaxDrawnItem >= totalCount)
+ return;
+
+ scrollTopItem++;
+ FixScrollPosition();
+ InvalidateRect(hwnd, 0, FALSE);
+}
+
+void NewstoryListData::PageUp()
+{
+ if (scrollTopItem <= 0)
+ return;
+
+ if (scrollTopPixel == 0)
+ scrollTopItem -= 10;
+ else {
+ cachedMaxTopItem -= 9;
+ scrollTopPixel = 0;
+ }
+ FixScrollPosition();
+ InvalidateRect(hwnd, 0, FALSE);
+}
+
+void NewstoryListData::PageDown()
+{
+ if (cachedMaxDrawnItem >= totalCount)
+ return;
+
+ scrollTopItem = cachedMaxDrawnItem - 1;
+ FixScrollPosition();
+ InvalidateRect(hwnd, 0, FALSE);
+}
+
+void NewstoryListData::ScrollTop()
+{
+ SetPos(0);
+}
+
+void NewstoryListData::ScrollBottom()
+{
+ if (totalCount)
+ SetPos(totalCount - 1);
+}
+
+
+/////////////////////////////////////////////////////////////////////////////////////////
// Edit box window procedure
static LRESULT CALLBACK HistoryEditWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -518,7 +586,7 @@ static LRESULT CALLBACK HistoryEditWndProc(HWND hwnd, UINT msg, WPARAM wParam, L
return CallWindowProc(OldEditWndProc, hwnd, msg, wParam, lParam);
}
-/////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////
// NewStory history control window procedure
LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -546,8 +614,6 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
SetWindowLongPtr(hwnd, 0, (LONG_PTR)data);
if (!g_plugin.bOptVScroll)
SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_VSCROLL);
- else
- data->RecalcScrollBar();
break;
// History list control messages
@@ -599,7 +665,7 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
if (idx >= 0) {
data->SetSelection(idx, idx);
- data->SetCaret(idx, true);
+ data->SetCaret(idx);
}
return idx;
@@ -610,7 +676,7 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
if (idx >= 0) {
data->SetSelection(idx, idx);
- data->SetCaret(idx, true);
+ data->SetCaret(idx);
}
return idx;
@@ -621,20 +687,20 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
auto *p = data->GetItem(i);
if (p->dbe.timestamp >= wParam) {
data->SetSelection(i, i);
- data->SetCaret(i, true);
+ data->SetCaret(i);
break;
}
if (i == eventCount - 1) {
data->SetSelection(i, i);
- data->SetCaret(i, true);
+ data->SetCaret(i);
}
}
}
return TRUE;
case NSM_SEEKEND:
- data->SetCaret(data->totalCount - 1, true);
+ data->SetCaret(data->totalCount - 1);
break;
case NSM_SET_SRMM:
@@ -736,6 +802,7 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
idx = data->scrollTopItem;
while ((top < height) && (idx < data->totalCount))
top += data->PaintItem(hdc, idx++, top, width);
+ data->cachedMaxDrawnItem = idx;
if (top <= height) {
RECT rc2;
@@ -746,6 +813,8 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
DeleteObject(hbr);
}
+ if (g_plugin.bOptVScroll)
+ data->RecalcScrollBar();
if (g_plugin.bDrawEdge)
DrawEdge(hdc, &rc, BDR_SUNKENOUTER, BF_RECT);
@@ -770,7 +839,7 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
if (data->caret != idx)
data->EndEditItem(false);
data->SetSelection(idx, idx);
- data->SetCaret(idx, true);
+ data->SetCaret(idx);
data->OnContextMenu(idx, pt);
}
break;
@@ -876,11 +945,11 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
if (wParam & MK_CONTROL) {
data->ToggleSelection(idx, idx);
- data->SetCaret(idx, true);
+ data->SetCaret(idx);
}
else if (wParam & MK_SHIFT) {
data->AddSelection(data->caret, idx);
- data->SetCaret(idx, true);
+ data->SetCaret(idx);
}
else {
pt.y -= pItem->savedTop;
@@ -892,7 +961,7 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
}
data->SetSelection(idx, idx);
- data->SetCaret(idx, true);
+ data->SetCaret(idx);
}
}
SetFocus(hwnd);
@@ -936,6 +1005,8 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
data->LineDown();
else
data->LineUp();
+ if (GetFocus() != hwnd)
+ OutputDebugStringA(CMStringA(FORMAT, "Currently focused window is %p", GetFocus()));
return TRUE;
case WM_VSCROLL:
diff --git a/plugins/NewStory/src/history_control.h b/plugins/NewStory/src/history_control.h
index e6ec51cdeb..c3a95a531a 100644
--- a/plugins/NewStory/src/history_control.h
+++ b/plugins/NewStory/src/history_control.h
@@ -73,6 +73,9 @@ struct NewstoryListData : public MZeroedObject
int cachedMaxTopItem; // the largest ID of top item to avoid empty space
int cachedMaxTopPixel;
int cachedWindowWidth = -1;
+ int cachedMaxDrawnItem = -1;
+ int cachedScrollbarPos = -1;
+ unsigned int cachedScrollbarPage = -1;
int totalCount;
RECT rcLastPaint;
@@ -99,56 +102,21 @@ struct NewstoryListData : public MZeroedObject
ItemData* GetItem(int idx);
int GetItemFromPixel(int yPos);
int GetItemHeight(int index);
+ void LineUp();
+ void LineDown();
ItemData* LoadItem(int idx);
+ void PageUp();
+ void PageDown();
int PaintItem(HDC hdc, int index, int top, int width);
void RecalcScrollBar();
void ScheduleDraw();
- void SetCaret(int idx, bool bEnsureVisible);
+ void ScrollTop();
+ void ScrollBottom();
+ void SetCaret(int idx, bool bEnsureVisible = true);
void SetPos(int pos);
void SetSelection(int iFirst, int iLast);
void ToggleBookmark();
void ToggleSelection(int iFirst, int iLast);
-
- void LineUp()
- {
- if (caret > 0)
- SetPos(caret - 1);
- }
-
- void LineDown()
- {
- if (caret < totalCount - 1)
- SetPos(caret + 1);
- }
-
- void PageUp()
- {
- if (caret > 10)
- SetPos(caret - 10);
- else
- SetPos(0);
- }
-
- void PageDown()
- {
- if (totalCount) {
- if (caret + 10 < totalCount - 1)
- SetPos(caret + 10);
- else
- SetPos(totalCount - 1);
- }
- }
-
- void ScrollTop()
- {
- SetPos(0);
- }
-
- void ScrollBottom()
- {
- if (totalCount)
- SetPos(totalCount - 1);
- }
};
void InitNewstoryControl();
diff --git a/plugins/NewStory/src/history_dlg.cpp b/plugins/NewStory/src/history_dlg.cpp
index 124b78bc5b..b138b8a924 100644
--- a/plugins/NewStory/src/history_dlg.cpp
+++ b/plugins/NewStory/src/history_dlg.cpp
@@ -429,6 +429,7 @@ public:
WindowList_Add(g_hNewstoryWindows, m_hwnd, m_hContact);
+ ShowHideControls();
UpdateTitle();
if (m_hContact != INVALID_CONTACT_ID) {
@@ -437,6 +438,7 @@ public:
ADDEVENTS tmp = { m_hContact, 0, -1 };
m_histControl.SendMsg(NSM_ADDEVENTS, WPARAM(&tmp), 0);
+ TimeTreeBuild();
SetFocus(m_histControl.GetHwnd());
}
else {
@@ -470,9 +472,6 @@ public:
SendMessage(ibTotal.hwndIco, STM_SETICON, (LPARAM)g_plugin.getIcon(IDI_UNKNOWN), 0);
SendMessage(ibTotal.hwndIcoIn, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(IDI_MSGIN));
SendMessage(ibTotal.hwndIcoOut, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(IDI_MSGOUT));
-
- ShowHideControls();
- TimeTreeBuild();
return true;
}
@@ -553,25 +552,25 @@ public:
hDwp = DeferWindowPos(hDwp, m_hwndChkDateFrom, 0,
w - x - (rc.right - rc.left) - WND_SPACING * 2, y,
x, rc.bottom - rc.top,
- SWP_NOZORDER);
+ SWP_NOZORDER | SWP_NOACTIVATE);
hDwp = DeferWindowPos(hDwp, m_hwndDateFrom, 0,
w - (rc.right - rc.left) - WND_SPACING, y,
rc.right - rc.left, rc.bottom - rc.top,
- SWP_NOZORDER);
+ SWP_NOZORDER | SWP_NOACTIVATE);
hDwp = DeferWindowPos(hDwp, m_hwndChkDateTo, 0,
w - x - (rc.right - rc.left) - WND_SPACING * 2, y + (rc.bottom - rc.top) + WND_SPACING,
x, rc.bottom - rc.top,
- SWP_NOZORDER);
+ SWP_NOZORDER | SWP_NOACTIVATE);
hDwp = DeferWindowPos(hDwp, m_hwndDateTo, 0,
w - (rc.right - rc.left) - WND_SPACING, y + (rc.bottom - rc.top) + WND_SPACING,
rc.right - rc.left, rc.bottom - rc.top,
- SWP_NOZORDER);
+ SWP_NOZORDER | SWP_NOACTIVATE);
hDwp = DeferWindowPos(hDwp, GetDlgItem(m_hwnd, IDC_IB_SEPARATOR), 0,
WND_SPACING, hToolBar + WND_SPACING,
w - WND_SPACING * 2, 2,
- SWP_NOZORDER);
+ SWP_NOZORDER | SWP_NOACTIVATE);
}
// general
@@ -580,7 +579,7 @@ public:
hDwp = DeferWindowPos(hDwp, m_hwndStatus, 0,
0, h - hStatus,
w, hStatus,
- SWP_NOZORDER);
+ SWP_NOZORDER | SWP_NOACTIVATE);
// search bar
int hSearch = 0;
@@ -589,19 +588,19 @@ public:
hSearch = rc.bottom - rc.top;
hDwp = DeferWindowPos(hDwp, m_hwndBtnCloseSearch, 0,
WND_SPACING, h - hSearch - hStatus - WND_SPACING,
- TBTN_SIZE, hSearch, SWP_NOZORDER);
+ TBTN_SIZE, hSearch, SWP_NOZORDER | SWP_NOACTIVATE);
hDwp = DeferWindowPos(hDwp, edtSearchText.GetHwnd(), 0,
TBTN_SIZE + WND_SPACING * 2, h - hSearch - hStatus - WND_SPACING,
w - WND_SPACING * 4 - TBTN_SIZE * 3, hSearch,
- SWP_NOZORDER);
+ SWP_NOZORDER | SWP_NOACTIVATE);
hDwp = DeferWindowPos(hDwp, btnFindPrev.GetHwnd(), 0,
w - WND_SPACING - TBTN_SIZE * 2, h - hSearch - hStatus - WND_SPACING,
TBTN_SIZE, hSearch,
- SWP_NOZORDER);
+ SWP_NOZORDER | SWP_NOACTIVATE);
hDwp = DeferWindowPos(hDwp, btnFindNext.GetHwnd(), 0,
w - WND_SPACING - TBTN_SIZE * 1, h - hSearch - hStatus - WND_SPACING,
TBTN_SIZE, hSearch,
- SWP_NOZORDER);
+ SWP_NOZORDER | SWP_NOACTIVATE);
hSearch += WND_SPACING;
}
@@ -612,13 +611,13 @@ public:
hDwp = DeferWindowPos(hDwp, m_timeTree.GetHwnd(), 0,
WND_SPACING, WND_SPACING + hToolBar + hFilterBar,
hTimeTree, h - WND_SPACING * 2 - hFilterBar - hToolBar - hSearch - hStatus,
- SWP_NOZORDER);
+ SWP_NOZORDER | SWP_NOACTIVATE);
}
hDwp = DeferWindowPos(hDwp, m_histControl.GetHwnd(), 0,
WND_SPACING + hTimeTree, WND_SPACING + hToolBar + hFilterBar,
w - WND_SPACING * 2 - hTimeTree, h - WND_SPACING * 2 - hFilterBar - hToolBar - hSearch - hStatus,
- SWP_NOZORDER);
+ SWP_NOZORDER | SWP_NOACTIVATE);
EndDeferWindowPos(hDwp);
}