diff options
author | George Hazan <ghazan@miranda.im> | 2018-04-20 13:35:23 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-04-20 13:35:23 +0300 |
commit | 25c5793e0be2d223cd8c3f562f574546cff81c30 (patch) | |
tree | 50431ecf084a2c69bb6c48d5140740997ded2c2d /src | |
parent | 0c8b5d434e1b2b68ba8f21cc5d5e192f95869dcb (diff) |
StdMsg: code cleaning
Diffstat (limited to 'src')
-rw-r--r-- | src/core/stdmsg/src/msgs.h | 65 | ||||
-rw-r--r-- | src/core/stdmsg/src/stdafx.h | 56 | ||||
-rw-r--r-- | src/core/stdmsg/src/tabs.cpp | 203 |
3 files changed, 162 insertions, 162 deletions
diff --git a/src/core/stdmsg/src/msgs.h b/src/core/stdmsg/src/msgs.h index a926188e0c..2c14795074 100644 --- a/src/core/stdmsg/src/msgs.h +++ b/src/core/stdmsg/src/msgs.h @@ -22,9 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef SRMM_MSGS_H
#define SRMM_MSGS_H
-#include <richedit.h>
-#include <richole.h>
-
#define DM_REMAKELOG (WM_USER+11)
#define HM_DBEVENTADDED (WM_USER+12)
#define DM_CASCADENEWWINDOW (WM_USER+13)
@@ -57,16 +54,16 @@ protected: CMsgDialog(int idDialog, SESSION_INFO *si = nullptr);
+public:
virtual void CloseTab() override;
+
+ __forceinline SESSION_INFO* getChat() const { return m_si; }
};
class CSrmmWindow : public CMsgDialog
{
- friend class CTabbedWindow;
typedef CMsgDialog CSuper;
- static LRESULT CALLBACK TabSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
-
virtual LRESULT WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam) override;
virtual LRESULT WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) override;
@@ -141,6 +138,62 @@ public: }
};
+/////////////////////////////////////////////////////////////////////////////////////////
+
+#define GC_ADDTAB (WM_USER+200)
+#define GC_REMOVETAB (WM_USER+201)
+#define GC_DROPPEDTAB (WM_USER+202)
+#define GC_RENAMETAB (WM_USER+203)
+
+class CChatRoomDlg : public CMsgDialog
+{
+ typedef CMsgDialog CSuper;
+ friend class CTabbedWindow;
+
+ static INT_PTR CALLBACK FilterWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
+
+ virtual LRESULT WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam) override;
+ virtual LRESULT WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) override;
+ virtual LRESULT WndProc_Nicklist(UINT msg, WPARAM wParam, LPARAM lParam) override;
+
+ wchar_t szTabSave[20];
+
+ CCtrlButton m_btnOk;
+ CSplitter m_splitterX, m_splitterY;
+ CTabbedWindow *m_pOwner;
+
+ int m_iSplitterX, m_iSplitterY;
+
+ void onActivate(void);
+
+public:
+ CChatRoomDlg(CTabbedWindow*, SESSION_INFO*);
+
+ virtual void OnInitDialog() override;
+ virtual void OnDestroy() override;
+
+ virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
+ virtual int Resizer(UTILRESIZECONTROL *urc) override;
+
+ virtual void LoadSettings() override;
+ virtual void RedrawLog() override;
+ virtual void StreamInEvents(LOGINFO *lin, bool bRedraw) override;
+ virtual void ScrollToBottom() override;
+ virtual void ShowFilterMenu() override;
+ virtual void UpdateNickList() override;
+ virtual void UpdateOptions() override;
+ virtual void UpdateStatusBar() override;
+ virtual void UpdateTitle() override;
+
+ void onClick_Ok(CCtrlButton*);
+
+ void onClick_Filter(CCtrlButton*);
+ void onClick_NickList(CCtrlButton*);
+
+ void onSplitterX(CSplitter*);
+ void onSplitterY(CSplitter*);
+};
+
INT_PTR CALLBACK ErrorDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
int DbEventIsForMsgWindow(DBEVENTINFO *dbei);
int DbEventIsShown(DBEVENTINFO *dbei);
diff --git a/src/core/stdmsg/src/stdafx.h b/src/core/stdmsg/src/stdafx.h index 2705dc8261..d9d52bc165 100644 --- a/src/core/stdmsg/src/stdafx.h +++ b/src/core/stdmsg/src/stdafx.h @@ -179,59 +179,3 @@ CTabbedWindow* GetContainer(); void TB_SaveSession(SESSION_INFO *si);
#pragma comment(lib,"comctl32.lib")
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-#define GC_ADDTAB (WM_USER+200)
-#define GC_REMOVETAB (WM_USER+201)
-#define GC_DROPPEDTAB (WM_USER+202)
-#define GC_RENAMETAB (WM_USER+203)
-
-class CChatRoomDlg : public CMsgDialog
-{
- typedef CMsgDialog CSuper;
- friend class CTabbedWindow;
-
- static INT_PTR CALLBACK FilterWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
-
- virtual LRESULT WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam) override;
- virtual LRESULT WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) override;
- virtual LRESULT WndProc_Nicklist(UINT msg, WPARAM wParam, LPARAM lParam) override;
-
- wchar_t szTabSave[20];
-
- CCtrlButton m_btnOk;
- CSplitter m_splitterX, m_splitterY;
- CTabbedWindow *m_pOwner;
-
- int m_iSplitterX, m_iSplitterY;
-
- void onActivate(void);
-
-public:
- CChatRoomDlg(CTabbedWindow*, SESSION_INFO*);
-
- virtual void OnInitDialog() override;
- virtual void OnDestroy() override;
-
- virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
- virtual int Resizer(UTILRESIZECONTROL *urc) override;
-
- virtual void LoadSettings() override;
- virtual void RedrawLog() override;
- virtual void StreamInEvents(LOGINFO *lin, bool bRedraw) override;
- virtual void ScrollToBottom() override;
- virtual void ShowFilterMenu() override;
- virtual void UpdateNickList() override;
- virtual void UpdateOptions() override;
- virtual void UpdateStatusBar() override;
- virtual void UpdateTitle() override;
-
- void onClick_Ok(CCtrlButton*);
-
- void onClick_Filter(CCtrlButton*);
- void onClick_NickList(CCtrlButton*);
-
- void onSplitterX(CSplitter*);
- void onSplitterY(CSplitter*);
-};
diff --git a/src/core/stdmsg/src/tabs.cpp b/src/core/stdmsg/src/tabs.cpp index 8d16a92200..f25439dd63 100644 --- a/src/core/stdmsg/src/tabs.cpp +++ b/src/core/stdmsg/src/tabs.cpp @@ -61,6 +61,108 @@ CTabbedWindow* GetContainer() ///////////////////////////////////////////////////////////////////////////////////////// +static LRESULT CALLBACK TabSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + CTabbedWindow *pOwner = (CTabbedWindow*)GetWindowLongPtr(hwnd, GWLP_USERDATA); + TCHITTESTINFO tci = {}; + + static bool bDragging = false; + static int iBeginIndex = 0; + switch (msg) { + case WM_LBUTTONDOWN: + tci.pt.x = (short)LOWORD(GetMessagePos()); + tci.pt.y = (short)HIWORD(GetMessagePos()); + if (DragDetect(hwnd, tci.pt) && TabCtrl_GetItemCount(hwnd) > 1) { + tci.flags = TCHT_ONITEM; + ScreenToClient(hwnd, &tci.pt); + int idx = TabCtrl_HitTest(hwnd, &tci); + if (idx != -1) { + CMsgDialog *pDlg = (CMsgDialog*)pOwner->m_tab.GetNthPage(idx); + if (pDlg) { + SESSION_INFO *si = pDlg->getChat(); + if (si != nullptr) { + bool bOnline = db_get_w(si->hContact, si->pszModule, "Status", ID_STATUS_OFFLINE) == ID_STATUS_ONLINE; + MODULEINFO *mi = pci->MM_FindModule(si->pszModule); + bDragging = true; + iBeginIndex = idx; + ImageList_BeginDrag(hIconsList, bOnline ? mi->OnlineIconIndex : mi->OfflineIconIndex, 8, 8); + ImageList_DragEnter(hwnd, tci.pt.x, tci.pt.y); + SetCapture(hwnd); + } + } + return TRUE; + } + } + else pOwner->TabClicked(); + break; + + case WM_CAPTURECHANGED: + bDragging = false; + ImageList_DragLeave(hwnd); + ImageList_EndDrag(); + break; + + case WM_MOUSEMOVE: + if (bDragging) { + tci.pt.x = (short)LOWORD(GetMessagePos()); + tci.pt.y = (short)HIWORD(GetMessagePos()); + ScreenToClient(hwnd, &tci.pt); + ImageList_DragMove(tci.pt.x, tci.pt.y); + } + break; + + case WM_LBUTTONUP: + if (bDragging && ReleaseCapture()) { + tci.pt.x = (short)LOWORD(GetMessagePos()); + tci.pt.y = (short)HIWORD(GetMessagePos()); + tci.flags = TCHT_ONITEM; + bDragging = false; + ImageList_DragLeave(hwnd); + ImageList_EndDrag(); + + ScreenToClient(hwnd, &tci.pt); + int idx = TabCtrl_HitTest(hwnd, &tci); + if (idx != -1 && idx != iBeginIndex) + SendMessage(GetParent(hwnd), GC_DROPPEDTAB, idx, iBeginIndex); + } + break; + + case WM_LBUTTONDBLCLK: + if (g_Settings.bTabCloseOnDblClick) { + tci.pt.x = (short)LOWORD(GetMessagePos()); + tci.pt.y = (short)HIWORD(GetMessagePos()); + ScreenToClient(hwnd, &tci.pt); + + tci.flags = TCHT_ONITEM; + int idx = TabCtrl_HitTest(hwnd, &tci); + if (idx != -1) { + CMsgDialog *pDlg = (CMsgDialog*)pOwner->m_tab.GetNthPage(idx); + if (pDlg) + pDlg->CloseTab(); + } + } + break; + + case WM_MBUTTONUP: + tci.pt.x = (short)LOWORD(GetMessagePos()); + tci.pt.y = (short)HIWORD(GetMessagePos()); + tci.flags = TCHT_ONITEM; + + ScreenToClient(hwnd, &tci.pt); + int idx = TabCtrl_HitTest(hwnd, &tci); + if (idx != -1) { + CMsgDialog *pDlg = (CMsgDialog*)pOwner->m_tab.GetNthPage(idx); + if (pDlg) + pDlg->CloseTab(); + } + break; + } + + return mir_callNextSubclass(hwnd, TabSubclassProc, msg, wParam, lParam); +} + +///////////////////////////////////////////////////////////////////////////////////////// + CTabbedWindow::CTabbedWindow() : CDlgBase(g_hInst, IDD_CONTAINER), m_tab(this, IDC_TAB), @@ -72,7 +174,7 @@ CTabbedWindow::CTabbedWindow() : void CTabbedWindow::OnInitDialog() { SetWindowLongPtr(m_tab.GetHwnd(), GWLP_USERDATA, LPARAM(this)); - mir_subclassWindow(m_tab.GetHwnd(), &CSrmmWindow::TabSubclassProc); + mir_subclassWindow(m_tab.GetHwnd(), ::TabSubclassProc); m_hwndStatus = CreateWindowEx(0, STATUSCLASSNAME, nullptr, WS_CHILD | WS_VISIBLE | SBT_TOOLTIPS | SBARS_SIZEGRIP, 0, 0, 0, 0, m_hwnd, nullptr, g_hInst, nullptr); SendMessage(m_hwndStatus, SB_SETMINHEIGHT, GetSystemMetrics(SM_CYSMICON), 0); @@ -319,105 +421,6 @@ void CTabbedWindow::TabClicked() ///////////////////////////////////////////////////////////////////////////////////////// -LRESULT CALLBACK CSrmmWindow::TabSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - CTabbedWindow *pOwner = (CTabbedWindow*)GetWindowLongPtr(hwnd, GWLP_USERDATA); - TCHITTESTINFO tci = {}; - int idx; - - static bool bDragging = false; - static int iBeginIndex = 0; - switch (msg) { - case WM_LBUTTONDOWN: - tci.pt.x = (short)LOWORD(GetMessagePos()); - tci.pt.y = (short)HIWORD(GetMessagePos()); - if (DragDetect(hwnd, tci.pt) && TabCtrl_GetItemCount(hwnd) > 1) { - tci.flags = TCHT_ONITEM; - ScreenToClient(hwnd, &tci.pt); - idx = TabCtrl_HitTest(hwnd, &tci); - if (idx != -1) { - CSrmmWindow *pDlg = (CSrmmWindow*)pOwner->m_tab.GetNthPage(idx); - if (pDlg) { - SESSION_INFO *si = pDlg->m_si; - if (si != nullptr) { - bool bOnline = db_get_w(si->hContact, si->pszModule, "Status", ID_STATUS_OFFLINE) == ID_STATUS_ONLINE; - MODULEINFO *mi = pci->MM_FindModule(si->pszModule); - bDragging = true; - iBeginIndex = idx; - ImageList_BeginDrag(hIconsList, bOnline ? mi->OnlineIconIndex : mi->OfflineIconIndex, 8, 8); - ImageList_DragEnter(hwnd, tci.pt.x, tci.pt.y); - SetCapture(hwnd); - } - } - return TRUE; - } - } - else pOwner->TabClicked(); - break; - - case WM_CAPTURECHANGED: - bDragging = false; - ImageList_DragLeave(hwnd); - ImageList_EndDrag(); - break; - - case WM_MOUSEMOVE: - if (bDragging) { - tci.pt.x = (short)LOWORD(GetMessagePos()); - tci.pt.y = (short)HIWORD(GetMessagePos()); - ScreenToClient(hwnd, &tci.pt); - ImageList_DragMove(tci.pt.x, tci.pt.y); - } - break; - - case WM_LBUTTONUP: - if (bDragging && ReleaseCapture()) { - tci.pt.x = (short)LOWORD(GetMessagePos()); - tci.pt.y = (short)HIWORD(GetMessagePos()); - tci.flags = TCHT_ONITEM; - bDragging = false; - ImageList_DragLeave(hwnd); - ImageList_EndDrag(); - - ScreenToClient(hwnd, &tci.pt); - idx = TabCtrl_HitTest(hwnd, &tci); - if (idx != -1 && idx != iBeginIndex) - SendMessage(GetParent(hwnd), GC_DROPPEDTAB, idx, iBeginIndex); - } - break; - - case WM_LBUTTONDBLCLK: - tci.pt.x = (short)LOWORD(GetMessagePos()); - tci.pt.y = (short)HIWORD(GetMessagePos()); - tci.flags = TCHT_ONITEM; - - ScreenToClient(hwnd, &tci.pt); - idx = TabCtrl_HitTest(hwnd, &tci); - if (idx != -1 && g_Settings.bTabCloseOnDblClick) { - CSrmmBaseDialog *pDlg = (CSrmmBaseDialog*)pOwner->m_tab.GetNthPage(idx); - if (pDlg) - pDlg->CloseTab(); - } - break; - - case WM_MBUTTONUP: - tci.pt.x = (short)LOWORD(GetMessagePos()); - tci.pt.y = (short)HIWORD(GetMessagePos()); - tci.flags = TCHT_ONITEM; - - ScreenToClient(hwnd, &tci.pt); - idx = TabCtrl_HitTest(hwnd, &tci); - if (idx != -1) { - CSrmmBaseDialog *pDlg = (CSrmmBaseDialog*)pOwner->m_tab.GetNthPage(idx); - if (pDlg) - pDlg->CloseTab(); - } - break; - } - - return mir_callNextSubclass(hwnd, TabSubclassProc, msg, wParam, lParam); -} - INT_PTR CTabbedWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) { int idx; |