Update Turkish translation
[dasher.git] / Src / Win32 / Widgets / Splitter.cpp
blobfbf729b27549ab996fc7986b73c166c79e3516bd
1 // Splitter.cpp
2 //
3 /////////////////////////////////////////////////////////////////////////////
4 //
5 // Copyright (c) 2002 Iain Murray, Inference Group, Cavendish, Cambridge.
6 //
7 /////////////////////////////////////////////////////////////////////////////
9 #include "WinCommon.h"
10 #include "Splitter.h"
12 #include <iostream>
13 #include <cstring>
14 #include <algorithm>
16 // For WinCE
17 #ifndef MAKEPOINTS
18 #define MAKEPOINTS(l) (*((POINTS FAR *) & (l)))
19 #endif
21 /////////////////////////////////////////////////////////////////////////////
23 CSplitter::CSplitter(CSplitterOwner* pOwner, int iPos)
24 : m_SplitStatus(None), m_iPos(iPos), m_pOwner(pOwner)
28 int CSplitter::GetHeight()
30 // (from MSDN) SM_CYSIZEFRAME:
31 // The thickness of the sizing border around the perimeter of a
32 // window that can be resized, in pixels.
33 // SM_CXSIZEFRAME is the width of the horizontal border, and
34 // SM_CYSIZEFRAME is the height of the vertical border.
35 return std::max(6, GetSystemMetrics(SM_CYSIZEFRAME));
38 /////////////////////////////////////////////////////////////////////////////
40 HWND CSplitter::Create(HWND hParent)
42 return CWindowImpl<CSplitter>::Create(hParent,NULL,NULL,WS_CHILD | WS_VISIBLE);
45 /////////////////////////////////////////////////////////////////////////////
47 void CSplitter::Move(int iPos, int Width)
49 m_iPos = iPos;
50 MoveWindow(0, m_iPos, Width, GetHeight(), TRUE);
53 /////////////////////////////////////////////////////////////////////////////
55 LRESULT CSplitter::OnLButtonDown(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
57 bHandled = TRUE;
58 m_SplitStatus = Sizing;
59 SetCapture();
60 return 0;
63 /////////////////////////////////////////////////////////////////////////////
65 LRESULT CSplitter::OnLButtonUp(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
67 bHandled = TRUE;
68 if( m_SplitStatus == Sizing)
70 m_SplitStatus = None;
71 ReleaseCapture();
73 return 0;
76 /////////////////////////////////////////////////////////////////////////////
78 LRESULT CSplitter::OnMouseMove(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
80 bHandled = TRUE;
82 if (m_SplitStatus == Sizing)
84 POINTS Tmp = MAKEPOINTS(lParam);
85 POINT MousePos;
86 MousePos.x = Tmp.x;
87 MousePos.y = Tmp.y;
88 MapWindowPoints(GetParent(), &MousePos, 1);
89 m_iPos = MousePos.y - GetHeight() / 2;
91 m_pOwner->Layout();
93 return 0;
95 /////////////////////////////////////////////////////////////////////////////