summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-03-03 22:52:31 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-03-03 22:52:31 +0300
commit62e2732278293e76cc00ac2f79a81c84bd8630f3 (patch)
tree512f5eb87bf41fe5adcaa48d8b16bc8aaac3abab /src
parent1974e62136d2bed460fe1ead68ff84aed5daee95 (diff)
StdMsg:
- these cursors aren't used anymore; - SplitterSubclassProc is not needed as well
Diffstat (limited to 'src')
-rw-r--r--src/core/stdmsg/src/chat_window.cpp116
-rw-r--r--src/core/stdmsg/src/msgdialog.cpp78
-rw-r--r--src/core/stdmsg/src/msgs.cpp11
-rw-r--r--src/core/stdmsg/src/msgs.h4
-rw-r--r--src/core/stdmsg/src/stdafx.h5
5 files changed, 63 insertions, 151 deletions
diff --git a/src/core/stdmsg/src/chat_window.cpp b/src/core/stdmsg/src/chat_window.cpp
index d4e544e1ec..a04ceee016 100644
--- a/src/core/stdmsg/src/chat_window.cpp
+++ b/src/core/stdmsg/src/chat_window.cpp
@@ -33,38 +33,6 @@ struct MESSAGESUBDATA
static wchar_t szTrimString[] = L":;,.!?\'\"><()[]- \r\n";
-static LRESULT CALLBACK SplitterSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- RECT rc;
-
- switch (msg) {
- case WM_NCHITTEST:
- return HTCLIENT;
-
- case WM_SETCURSOR:
- GetClientRect(hwnd, &rc);
- SetCursor(rc.right > rc.bottom ? LoadCursor(NULL, IDC_SIZENS) : LoadCursor(NULL, IDC_SIZEWE));
- return TRUE;
-
- case WM_LBUTTONDOWN:
- SetCapture(hwnd);
- return 0;
-
- case WM_MOUSEMOVE:
- if (GetCapture() == hwnd) {
- GetClientRect(hwnd, &rc);
- SendMessage(GetParent(hwnd), GC_SPLITTERMOVED, rc.right > rc.bottom ? (short)HIWORD(GetMessagePos()) + rc.bottom / 2 : (short)LOWORD(GetMessagePos()) + rc.right / 2, (LPARAM)hwnd);
- }
- return 0;
-
- case WM_LBUTTONUP:
- ReleaseCapture();
- PostMessage(GetParent(hwnd), WM_SIZE, 0, 0);
- return 0;
- }
- return mir_callNextSubclass(hwnd, SplitterSubclassProc, msg, wParam, lParam);
-}
-
int CChatRoomDlg::RoomWndResize(HWND, LPARAM lParam, UTILRESIZECONTROL *urc)
{
CChatRoomDlg *dat = (CChatRoomDlg*)lParam;
@@ -877,7 +845,10 @@ CChatRoomDlg::CChatRoomDlg(SESSION_INFO *si) :
m_btnFilter(this, IDC_FILTER),
m_btnHistory(this, IDC_HISTORY),
m_btnNickList(this, IDC_SHOWNICKLIST),
- m_btnChannelMgr(this, IDC_CHANMGR)
+ m_btnChannelMgr(this, IDC_CHANMGR),
+
+ m_splitterX(this, IDC_SPLITTERX),
+ m_splitterY(this, IDC_SPLITTERY)
{
m_pLog = &m_log;
m_pEntry = &m_message;
@@ -900,6 +871,9 @@ CChatRoomDlg::CChatRoomDlg(SESSION_INFO *si) :
m_btnNickList.OnClick = Callback(this, &CChatRoomDlg::OnClick_NickList);
m_nickList.OnDblClick = Callback(this, &CChatRoomDlg::OnListDblclick);
+
+ m_splitterX.OnChange = Callback(this, &CChatRoomDlg::OnSplitterX);
+ m_splitterY.OnChange = Callback(this, &CChatRoomDlg::OnSplitterY);
}
void CChatRoomDlg::OnInitDialog()
@@ -916,8 +890,7 @@ void CChatRoomDlg::OnInitDialog()
WindowList_Add(pci->hWindowList, m_hwnd, m_hContact);
NotifyLocalWinEvent(m_hContact, m_hwnd, MSG_WINDOW_EVT_OPENING);
- mir_subclassWindow(GetDlgItem(m_hwnd, IDC_SPLITTERX), SplitterSubclassProc);
- mir_subclassWindow(GetDlgItem(m_hwnd, IDC_SPLITTERY), SplitterSubclassProc);
+
mir_subclassWindow(m_log.GetHwnd(), LogSubclassProc);
mir_subclassWindow(m_btnFilter.GetHwnd(), ButtonSubclassProc);
mir_subclassWindow(m_btnColor.GetHwnd(), ButtonSubclassProc);
@@ -1131,6 +1104,35 @@ void CChatRoomDlg::OnListDblclick(CCtrlListBox*)
else pci->DoEventHookAsync(m_hwnd, m_si->ptszID, m_si->pszModule, GC_USER_PRIVMESS, ui, nullptr, 0);
}
+void CChatRoomDlg::OnSplitterX(CSplitter *pSplitter)
+{
+ RECT rc;
+ GetClientRect(m_hwnd, &rc);
+
+ m_si->iSplitterX = rc.right - pSplitter->GetPos() + 1;
+ if (m_si->iSplitterX < 35)
+ m_si->iSplitterX = 35;
+ if (m_si->iSplitterX > rc.right - rc.left - 35)
+ m_si->iSplitterX = rc.right - rc.left - 35;
+ g_Settings.iSplitterX = m_si->iSplitterX;
+}
+
+void CChatRoomDlg::OnSplitterY(CSplitter *pSplitter)
+{
+ RECT rc;
+ GetClientRect(m_hwnd, &rc);
+
+ m_si->iSplitterY = rc.bottom - pSplitter->GetPos() + 1;
+ if (!IsWindowVisible(m_btnBold.GetHwnd()))
+ m_si->iSplitterY += 19;
+
+ if (m_si->iSplitterY < 63)
+ m_si->iSplitterY = 63;
+ if (m_si->iSplitterY > rc.bottom - rc.top - 40)
+ m_si->iSplitterY = rc.bottom - rc.top - 40;
+ g_Settings.iSplitterY = m_si->iSplitterY;
+}
+
void CChatRoomDlg::SetWindowPosition()
{
if (g_Settings.bTabsEnable)
@@ -1547,50 +1549,6 @@ LABEL_SHOWWINDOW:
}
break;
- case GC_SPLITTERMOVED:
- {
- static int x = 0;
-
- RECT rcLog;
- GetWindowRect(m_log.GetHwnd(), &rcLog);
-
- if ((HWND)lParam == GetDlgItem(m_hwnd, IDC_SPLITTERX)) {
- int oldSplitterX;
- GetClientRect(m_hwnd, &rc);
- POINT pt = { wParam, 0 };
- ScreenToClient(m_hwnd, &pt);
-
- oldSplitterX = m_si->iSplitterX;
- m_si->iSplitterX = rc.right - pt.x + 1;
- if (m_si->iSplitterX < 35)
- m_si->iSplitterX = 35;
- if (m_si->iSplitterX > rc.right - rc.left - 35)
- m_si->iSplitterX = rc.right - rc.left - 35;
- g_Settings.iSplitterX = m_si->iSplitterX;
- }
- else if ((HWND)lParam == GetDlgItem(m_hwnd, IDC_SPLITTERY)) {
- BOOL bFormat = IsWindowVisible(m_btnBold.GetHwnd());
- int oldSplitterY;
- GetClientRect(m_hwnd, &rc);
- POINT pt = { 0, wParam };
- ScreenToClient(m_hwnd, &pt);
-
- oldSplitterY = m_si->iSplitterY;
- m_si->iSplitterY = bFormat ? rc.bottom - pt.y + 1 : rc.bottom - pt.y + 20;
- if (m_si->iSplitterY < 63)
- m_si->iSplitterY = 63;
- if (m_si->iSplitterY > rc.bottom - rc.top - 40)
- m_si->iSplitterY = rc.bottom - rc.top - 40;
- g_Settings.iSplitterY = m_si->iSplitterY;
- }
- if (x == 2) {
- PostMessage(m_hwnd, WM_SIZE, 0, 0);
- x = 0;
- }
- else x++;
- }
- break;
-
case GC_FIREHOOK:
if (lParam) {
GCHOOK *gch = (GCHOOK *)lParam;
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp
index 5eeacef419..345107d711 100644
--- a/src/core/stdmsg/src/msgdialog.cpp
+++ b/src/core/stdmsg/src/msgdialog.cpp
@@ -339,39 +339,6 @@ static LRESULT CALLBACK MessageEditSubclassProc(HWND hwnd, UINT msg, WPARAM wPar
return mir_callNextSubclass(hwnd, MessageEditSubclassProc, msg, wParam, lParam);
}
-static LRESULT CALLBACK SplitterSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- switch (msg) {
- case WM_NCHITTEST:
- return HTCLIENT;
-
- case WM_SETCURSOR:
- {
- RECT rc;
- GetClientRect(hwnd, &rc);
- SetCursor(rc.right > rc.bottom ? hCurSplitNS : hCurSplitWE);
- }
- return TRUE;
-
- case WM_LBUTTONDOWN:
- SetCapture(hwnd);
- return 0;
-
- case WM_MOUSEMOVE:
- if (GetCapture() == hwnd) {
- RECT rc;
- GetClientRect(hwnd, &rc);
- SendMessage(GetParent(hwnd), DM_SPLITTERMOVED, rc.right > rc.bottom ? (short)HIWORD(GetMessagePos()) + rc.bottom / 2 : (short)LOWORD(GetMessagePos()) + rc.right / 2, (LPARAM)hwnd);
- }
- return 0;
-
- case WM_LBUTTONUP:
- ReleaseCapture();
- return 0;
- }
- return mir_callNextSubclass(hwnd, SplitterSubclassProc, msg, wParam, lParam);
-}
-
static int MessageDialogResize(HWND, LPARAM lParam, UTILRESIZECONTROL *urc)
{
CSrmmWindow *dat = (CSrmmWindow*)lParam;
@@ -418,6 +385,7 @@ CSrmmWindow::CSrmmWindow(MCONTACT hContact, bool noActivate, const char *szIniti
CSrmmBaseDialog(g_hInst, IDD_MSG),
m_log(this, IDC_LOG),
m_message(this, IDC_MESSAGE),
+ m_splitter(this, IDC_SPLITTERY),
m_cmdList(20),
m_bNoActivate(noActivate)
{
@@ -426,6 +394,8 @@ CSrmmWindow::CSrmmWindow(MCONTACT hContact, bool noActivate, const char *szIniti
m_hContact = hContact;
m_wszInitialText = (bIsUnicode) ? mir_wstrdup((wchar_t*)szInitialText) : mir_a2u(szInitialText);
+
+ m_splitter.OnChange = Callback(this, &CSrmmWindow::OnSplitterMoved);
}
void CSrmmWindow::OnInitDialog()
@@ -495,8 +465,6 @@ void CSrmmWindow::OnInitDialog()
mir_subclassWindow(m_message.GetHwnd(), MessageEditSubclassProc);
m_message.SendMsg(EM_SUBCLASSED, 0, 0);
- mir_subclassWindow(GetDlgItem(m_hwnd, IDC_SPLITTERY), SplitterSubclassProc);
-
if (m_hContact) {
int historyMode = db_get_b(NULL, SRMMMOD, SRMSGSET_LOADHISTORY, SRMSGDEFSET_LOADHISTORY);
// This finds the first message to display, it works like shit
@@ -739,6 +707,21 @@ void CSrmmWindow::OnOptionsApplied(bool bUpdateAvatar)
SendMessage(m_hwnd, DM_UPDATEWINICON, 0, 0);
}
+void CSrmmWindow::OnSplitterMoved(CSplitter *pSplitter)
+{
+ RECT rc, rcLog;
+ GetClientRect(m_hwnd, &rc);
+ GetWindowRect(m_log.GetHwnd(), &rcLog);
+
+ int oldSplitterY = m_splitterPos;
+ m_splitterPos = rc.bottom - pSplitter->GetPos() + 23;
+ GetWindowRect(m_message.GetHwnd(), &rc);
+ if (rc.bottom - rc.top + (m_splitterPos - oldSplitterY) < m_minEditBoxSize.cy)
+ m_splitterPos = oldSplitterY + m_minEditBoxSize.cy - (rc.bottom - rc.top);
+ if (rcLog.bottom - rcLog.top - (m_splitterPos - oldSplitterY) < m_minEditBoxSize.cy)
+ m_splitterPos = oldSplitterY - m_minEditBoxSize.cy + (rcLog.bottom - rcLog.top);
+}
+
void CSrmmWindow::NotifyTyping(int mode)
{
if (!m_hContact)
@@ -937,7 +920,7 @@ INT_PTR CSrmmWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
RECT rc;
GetWindowRect(m_message.GetHwnd(), &rc);
if (rc.bottom - rc.top < m_minEditBoxSize.cy)
- SendMessage(m_hwnd, DM_SPLITTERMOVED, rc.top - (rc.bottom - rc.top - m_minEditBoxSize.cy - 4), (LPARAM)GetDlgItem(m_hwnd, IDC_SPLITTERY));
+ m_splitter.OnChange(&m_splitter);
SendMessage(m_hwnd, WM_SIZE, 0, 0);
}
@@ -1127,29 +1110,6 @@ INT_PTR CSrmmWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
}
return TRUE;
- case DM_SPLITTERMOVED:
- if ((HWND)lParam == GetDlgItem(m_hwnd, IDC_SPLITTERY)) {
- RECT rc, rcLog;
- GetClientRect(m_hwnd, &rc);
- GetWindowRect(m_log.GetHwnd(), &rcLog);
-
- POINT pt;
- pt.x = 0;
- pt.y = wParam;
- ScreenToClient(m_hwnd, &pt);
-
- int oldSplitterY = m_splitterPos;
- m_splitterPos = rc.bottom - pt.y + 23;
- GetWindowRect(m_message.GetHwnd(), &rc);
- if (rc.bottom - rc.top + (m_splitterPos - oldSplitterY) < m_minEditBoxSize.cy)
- m_splitterPos = oldSplitterY + m_minEditBoxSize.cy - (rc.bottom - rc.top);
- if (rcLog.bottom - rcLog.top - (m_splitterPos - oldSplitterY) < m_minEditBoxSize.cy)
- m_splitterPos = oldSplitterY - m_minEditBoxSize.cy + (rcLog.bottom - rcLog.top);
-
- SendMessage(m_hwnd, WM_SIZE, 0, 0);
- }
- break;
-
case DM_REMAKELOG:
StreamInEvents(m_hDbEventFirst, -1, 0);
break;
diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp
index 4bc28191a7..be52d63040 100644
--- a/src/core/stdmsg/src/msgs.cpp
+++ b/src/core/stdmsg/src/msgs.cpp
@@ -30,7 +30,6 @@ const CLSID IID_IRichEditOleCallback = { 0x00020D03, 0x00, 0x00, { 0xC0, 0x00, 0
int OnCheckPlugins(WPARAM, LPARAM);
-HCURSOR hCurSplitNS, hCurSplitWE, hCurHyperlinkHand;
HANDLE hHookWinEvt, hHookWinPopup, hHookWinWrite;
HGENMENU hMsgMenuItem;
HMODULE hMsftEdit;
@@ -576,22 +575,12 @@ int LoadSendRecvMessageModule(void)
SkinAddNewSoundEx("TNStart", LPGEN("Instant messages"), LPGEN("Contact started typing"));
SkinAddNewSoundEx("TNStop", LPGEN("Instant messages"), LPGEN("Contact stopped typing"));
- hCurSplitNS = LoadCursor(NULL, IDC_SIZENS);
- hCurSplitWE = LoadCursor(NULL, IDC_SIZEWE);
- hCurHyperlinkHand = LoadCursor(NULL, IDC_HAND);
- if (hCurHyperlinkHand == NULL)
- hCurHyperlinkHand = LoadCursor(g_hInst, MAKEINTRESOURCE(IDC_HYPERLINKHAND));
-
InitStatusIcons();
return 0;
}
void SplitmsgShutdown(void)
{
- DestroyCursor(hCurSplitNS);
- DestroyCursor(hCurHyperlinkHand);
- DestroyCursor(hCurSplitWE);
-
DestroyHookableEvent(hHookWinEvt);
DestroyHookableEvent(hHookWinPopup);
DestroyHookableEvent(hHookWinWrite);
diff --git a/src/core/stdmsg/src/msgs.h b/src/core/stdmsg/src/msgs.h
index 1f269acdeb..9cfe81aa0b 100644
--- a/src/core/stdmsg/src/msgs.h
+++ b/src/core/stdmsg/src/msgs.h
@@ -29,7 +29,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define HM_DBEVENTADDED (WM_USER+12)
#define DM_CASCADENEWWINDOW (WM_USER+13)
#define DM_OPTIONSAPPLIED (WM_USER+14)
-#define DM_SPLITTERMOVED (WM_USER+15)
#define DM_UPDATETITLE (WM_USER+16)
#define DM_APPENDTOLOG (WM_USER+17)
#define DM_NEWTIMEZONE (WM_USER+18)
@@ -51,6 +50,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
class CSrmmWindow : public CSrmmBaseDialog
{
CCtrlEdit m_log, m_message;
+ CSplitter m_splitter;
void NotifyTyping(int mode);
void ShowAvatar(void);
@@ -100,6 +100,8 @@ public:
virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
+ void OnSplitterMoved(CSplitter*);
+
void OnOptionsApplied(bool bUpdateAvatar);
void SetStatusData(StatusTextData*);
diff --git a/src/core/stdmsg/src/stdafx.h b/src/core/stdmsg/src/stdafx.h
index f39b6c0199..236b5761db 100644
--- a/src/core/stdmsg/src/stdafx.h
+++ b/src/core/stdmsg/src/stdafx.h
@@ -78,7 +78,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define EM_ACTIVATE (WM_USER+0x102)
extern HINSTANCE g_hInst;
-extern HCURSOR hCurSplitNS, hCurSplitWE, hCurHyperlinkHand;
extern HANDLE hHookWinEvt, hHookWinPopup, hHookWinWrite;
extern CREOleCallback reOleCallback;
@@ -185,6 +184,7 @@ class CChatRoomDlg : public CSrmmBaseDialog
CCtrlButton m_btnOk;
CCtrlButton m_btnFilter, m_btnChannelMgr, m_btnNickList, m_btnHistory;
CCtrlButton m_btnBold, m_btnItalic, m_btnUnderline, m_btnColor, m_btnBkColor;
+ CSplitter m_splitterX, m_splitterY;
HWND getCaptionWindow() const
{ return (g_Settings.bTabsEnable) ? GetParent(m_hwndParent) : m_hwnd;
@@ -213,4 +213,7 @@ public:
void OnClick_NickList(CCtrlButton*);
void OnListDblclick(CCtrlListBox*);
+
+ void OnSplitterX(CSplitter*);
+ void OnSplitterY(CSplitter*);
};