#ifndef LAYOUT_H #define LAYOUT_H #include #include "common.h" #include "datalistview.h" void UpdateLayout(int w = 0, int h = 0); struct Dragger { bool HandleDown(); bool HandleMove(); private: bool InDragArea(int x, int y); bool IsDown(); bool IsDouble(); void Drag(int x, int y); bool m_bActive = false; long m_time = 0; }; inline bool Dragger::IsDouble() { const long time = GetMessageTime(); const bool dbl = time-m_time <= static_cast(GetDoubleClickTime()); m_time = time; return dbl; } inline bool Dragger::IsDown() { return GetKeyState(VK_LBUTTON) & 0x8000; } inline bool Dragger::HandleDown() { extern HWND g_hWnd; POINT pt; require(GetRelativeCursorPos(g_hWnd, &pt)); if (!InDragArea(pt.x, pt.y)) return false; if (IsDouble()) { extern DataListView* g_dlv; g_dlv->SetHeight(0); UpdateLayout(); return false; } else return m_bActive = true; } inline bool Dragger::HandleMove() { extern HWND g_hWnd; POINT pt; require(GetRelativeCursorPos(g_hWnd, &pt)); extern HCURSOR g_hcSizeNs; bool r = true; if (InDragArea(pt.x, pt.y)) SetCursor(g_hcSizeNs); else r = false; if (m_bActive) Drag(pt.x, pt.y); if (!IsDown()) m_bActive = false; return r; } #endif