summaryrefslogtreecommitdiff
path: root/plugins/TabSRMM/src/controls.h
blob: 93e72f351e01bed3b9d78394c5344fa9df604c82 (plain)
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/////////////////////////////////////////////////////////////////////////////////////////
// Miranda NG: the free IM client for Microsoft* Windows*
//
// Copyright (ñ) 2012-17 Miranda NG project,
// Copyright (c) 2000-09 Miranda ICQ/IM project,
// all portions of this codebase are copyrighted to the people
// listed in contributors.txt.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// you should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//
// part of tabSRMM messaging plugin for Miranda.
//
// (C) 2005-2010 by silvercircle _at_ gmail _dot_ com and contributors
//
// menu bar and status bar classes for the container window.

#ifndef __CONTROLS_H
#define __CONTROLS_H

class CMenuBar : public MZeroedObject
{
public:
	enum {
		NR_BUTTONS = 8
	};

	CMenuBar(HWND hwndParent, const TContainerData *pContainer);
	~CMenuBar();

	const RECT&  getClientRect();
	void         Resize(WORD wWidth) const
	{
		::SetWindowPos(m_hwndToolbar, 0, 4, 0, wWidth, m_size_y, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS | SWP_NOREDRAW);
	}

	LONG         getHeight() const;
	void         Show(int showCmd) const
	{
		::ShowWindow(m_hwndToolbar, showCmd);
	}
	LONG_PTR     Handle(const NMTOOLBAR *nmtb);
	void         Cancel();
	LONG_PTR     processMsg(const UINT msg, const WPARAM wParam, const LPARAM lParam);
	bool         isContactMenu() const { return(m_isContactMenu); }
	bool         isMainMenu() const { return(m_isMainMenu); }
	void         configureMenu(void) const;
	void         resetLP(void);
	void         setActive(HMENU hMenu)
	{
		m_activeSubMenu = hMenu;
	}
	void			setAero(bool fState) { m_isAero = fState; }
	const bool		getAero(void) const { return(m_isAero); }

	const LRESULT	processAccelerator(wchar_t a, UINT& ctlId) const
	{
		UINT		_ctlId;

		const LRESULT result = ::SendMessage(m_hwndToolbar, TB_MAPACCELERATOR, (WPARAM)a, (LPARAM)&_ctlId);
		ctlId = _ctlId;

		return(result);
	}
	void autoShow(const int showcmd = 1);

	const int	idToIndex(const int id) const
	{
		for (int i = 0; i < NR_BUTTONS; i++) {
			if (m_TbButtons[i].idCommand == id)
				return(i);
		}
		return -1;
	}
public:
	static   HHOOK   m_hHook;
	static   HBITMAP m_MimIcon;

private:
	HWND     m_hwndToolbar;
	RECT     m_rcClient;
	TContainerData *m_pContainer;
	HMENU    m_activeMenu, m_activeSubMenu;
	int      m_activeID;
	bool     m_fTracking;
	bool     m_isContactMenu;
	bool     m_isMainMenu;
	bool     m_isAero;
	bool     m_mustAutoHide;
	LONG     m_size_y;

	/*
	 * for custom drawing
	 */
	RECT     m_rcItem;
	HDC      m_hdcDraw;
	HBITMAP  m_hbmDraw, m_hbmOld;
	HANDLE   m_hTheme;
	HFONT    m_hOldFont;

	static   TBBUTTON m_TbButtons[8];
	static   bool m_buttonsInit;
	static   CMenuBar *m_Owner;
	static   int m_MimIconRefCount;
private:
	LONG_PTR	 customDrawWorker(NMCUSTOMDRAW *nm);
	void		 updateState(const HMENU hMenu) const;
	void		 invoke(const int id);
	void		 cancel();
	void 		 obtainHook();
	void		 releaseHook();
	void      checkButtons();

	static 		LRESULT CALLBACK wndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);		// subclassing for the toolbar control
	static 		LRESULT CALLBACK MessageHook(int nCode, WPARAM wParam, LPARAM lParam);				// message hook (only active when modal menus are active)
};

#endif /* __CONTROLS_H */