1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
#include <windows.h>
#include "datalistview.h"
#include "drag.h"
#include "episodelistview.h"
#include "win32.h"
#include "window.h"
bool Dragger::IsDouble(const long time, const POINT& pt)
{
const bool dbl = time-m_time0 <= static_cast<long>(GetDoubleClickTime())
&& abs(pt.x-m_pt0.x) <= Metric<SM_CXDOUBLECLK>
&& abs(pt.y-m_pt0.y) <= Metric<SM_CYDOUBLECLK>;
m_time0 = time;
m_pt0 = std::move(pt);
return dbl;
}
bool Dragger::IsDown() const
{
return GetKeyState(VK_LBUTTON) & 0x8000;
}
bool Dragger::HandleLButtonDown()
{
POINT pt;
if (!GetRelativeCursorPos(parent.hWnd, &pt))
throw Err(WINDOWS, L"Mouse cursor position could not be retrieved");
if (!InDragArea(pt.x, pt.y)) return false;
if (IsDouble(GetMessageTime(), pt)) {
m_bActive = false;
Reset();
} else
m_bActive = true;
return m_bActive;
}
bool Dragger::HandleSetCursor()
{
POINT pt;
if (!GetRelativeCursorPos(parent.hWnd, &pt))
throw Err(WINDOWS, L"Mouse cursor position could not be retrieved");
extern HCURSOR g_hcSizeNs;
bool r = true;
if (InDragArea(pt.x, pt.y))
SetCursor(g_hcSizeNs);
else
r = false;
if (!m_bActive)
return r;
Drag(pt.x, pt.y);
if (!IsDown()) {
m_bActive = false;
Done();
}
return r;
}
bool DlvDragger::InDragArea(const int x, const int y) const
{
RECT rrDlv;
if (!GetRelativeRect(parent.dlv.hWnd, &rrDlv))
throw Err(WINDOWS, L"Data list view rectangle could not be retrieved");
const int pad = EBIsThemeActive()? Dpi(6): 0;
const int extra = EBIsThemeActive()? 0: Dpi(2);
if (x < rrDlv.left || x > rrDlv.right) return false;
if (y < rrDlv.top-pad*2-extra*3 || y > rrDlv.top+extra) return false;
return true;
}
void DlvDragger::Drag(const int, const int y) const
{
RECT rrDlv;
if (!GetRelativeRect(parent.dlv.hWnd, &rrDlv))
throw Err(WINDOWS, L"Data list view rectangle could not be retrieved");
if (y < Dpi(50) || y > rrDlv.bottom-Dpi(20)) return;
int h;
h = rrDlv.bottom-y;
parent.dlv.SetHeight(h);
parent.UpdateLayout();
RedrawWindow(parent.hWnd, nullptr, nullptr,
RDW_ERASE|RDW_FRAME|RDW_INVALIDATE|RDW_ALLCHILDREN|RDW_UPDATENOW);
}
void DlvDragger::Reset() const
{
parent.dlv.SetHeight(0);
parent.cfg.heightDlv = 0;
parent.UpdateLayout();
}
void DlvDragger::Done() const
{
parent.cfg.heightDlv = parent.dlv.Height();
}
|