summaryrefslogtreecommitdiff
path: root/plugins/Clist_modern/src/hdr/modern_clui.h
blob: 0b8cc4f9e1cb5cc86e0c8a30d8bcff14d9e0726f (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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/*

Miranda IM: the free IM client for Microsoft* Windows*

Copyright 2000-2008 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.
*/
#ifndef modern_clui_h__
#define modern_clui_h__

#include "windowsX.h"
#define HANDLE_MESSAGE( _message, _fn)    \
	case (_message): return This->_fn((_message), (wParam), (lParam))

class CLUI
{
public:
	static HWND   m_hWnd;
	static CLUI * m_pCLUI;
	static BOOL   m_fMainMenuInited;

private:
	CLUI();			// is protected use InitClui to initialize instead

public:
	~CLUI();

	static HRESULT InitClui()         { m_pCLUI = new CLUI(); return S_OK; };
	static HWND&   ClcWnd()           { return pcli->hwndContactTree; }
	static HWND&   CluiWnd()          { return pcli->hwndContactList; }
	static CLUI *  GetClui()          { return m_pCLUI; } 
	static BOOL    IsMainMenuInited() { return CLUI::m_fMainMenuInited; }

	CLINTERFACE void cliOnCreateClc();

	EVENTHOOK( OnEvent_ModulesLoaded );
	EVENTHOOK( OnEvent_ContactMenuPreBuild );
	EVENTHOOK( OnEvent_FontReload );
	
	SERVICE( Service_ShowMainMenu );
	SERVICE( Service_ShowStatusMenu );
	SERVICE( Service_Menu_ShowContactAvatar );
	SERVICE( Service_Menu_HideContactAvatar );

	static LRESULT CALLBACK cli_ContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
	{
		CLUI * This = m_pCLUI;
		if ( !m_hWnd ) m_hWnd = hwnd;

		BOOL bHandled = FALSE;
		LRESULT lRes= This->PreProcessWndProc( msg, wParam, lParam, bHandled ); 
		if ( bHandled ) return lRes;

		switch ( msg )
		{
			HANDLE_MESSAGE( WM_NCCREATE,				OnNcCreate );
			HANDLE_MESSAGE( WM_CREATE,					OnCreate );
			HANDLE_MESSAGE( UM_CREATECLC,				OnCreateClc );
			HANDLE_MESSAGE( UM_SETALLEXTRAICONS,		OnSetAllExtraIcons );
			HANDLE_MESSAGE( WM_INITMENU,				OnInitMenu );
			HANDLE_MESSAGE( WM_SIZE,					OnSizingMoving );
			HANDLE_MESSAGE( WM_SIZING,					OnSizingMoving );
			HANDLE_MESSAGE( WM_MOVE,					OnSizingMoving );
			HANDLE_MESSAGE( WM_EXITSIZEMOVE,			OnSizingMoving );
			HANDLE_MESSAGE( WM_WINDOWPOSCHANGING,		OnSizingMoving );
			HANDLE_MESSAGE( WM_DISPLAYCHANGE,			OnSizingMoving );
			HANDLE_MESSAGE( WM_THEMECHANGED,			OnThemeChanged );
			HANDLE_MESSAGE( WM_DWMCOMPOSITIONCHANGED,	OnDwmCompositionChanged );
			HANDLE_MESSAGE( UM_SYNCCALL,				OnSyncCall );
			HANDLE_MESSAGE( UM_UPDATE,					OnUpdate );
			HANDLE_MESSAGE( WM_NCACTIVATE,				OnNcPaint );
			HANDLE_MESSAGE( WM_PRINT,					OnNcPaint );
			HANDLE_MESSAGE( WM_NCPAINT,					OnNcPaint );
			HANDLE_MESSAGE( WM_ERASEBKGND,				OnEraseBkgnd );
			HANDLE_MESSAGE( WM_PAINT,					OnPaint );
			HANDLE_MESSAGE( WM_LBUTTONDOWN,				OnLButtonDown );
			HANDLE_MESSAGE( WM_PARENTNOTIFY,			OnParentNotify );
			HANDLE_MESSAGE( WM_SETFOCUS,				OnSetFocus );
			HANDLE_MESSAGE( WM_TIMER,					OnTimer );
			HANDLE_MESSAGE( WM_ACTIVATE,				OnActivate );
			HANDLE_MESSAGE( WM_SETCURSOR,				OnSetCursor );
			HANDLE_MESSAGE( WM_MOUSEACTIVATE,			OnMouseActivate );
			HANDLE_MESSAGE( WM_NCLBUTTONDOWN,			OnNcLButtonDown );
			HANDLE_MESSAGE( WM_NCLBUTTONDBLCLK,			OnNcLButtonDblClk );
			HANDLE_MESSAGE( WM_NCHITTEST,				OnNcHitTest );
			HANDLE_MESSAGE( WM_SHOWWINDOW,				OnShowWindow );
			HANDLE_MESSAGE( WM_SYSCOMMAND,				OnSysCommand );
			HANDLE_MESSAGE( WM_KEYDOWN,					OnKeyDown );
			HANDLE_MESSAGE( WM_GETMINMAXINFO,			OnGetMinMaxInfo );
			HANDLE_MESSAGE( WM_MOVING,					OnMoving );
			HANDLE_MESSAGE( WM_NOTIFY,					OnNotify );
			HANDLE_MESSAGE( WM_CONTEXTMENU,				OnContextMenu );
			HANDLE_MESSAGE( WM_MEASUREITEM,				OnMeasureItem );
			HANDLE_MESSAGE( WM_DRAWITEM,				OnDrawItem );
			HANDLE_MESSAGE( WM_DESTROY,					OnDestroy );
		default:
			return This->DefCluiWndProc( msg, wParam, lParam );
		}
		return FALSE;
	}


	//////////////////////////////////////////////////////////////////////////
	// METHODS
	//
private:
	HRESULT CreateCLC();
	HRESULT FillAlphaChannel( HDC hDC, RECT* prcParent, BYTE bAlpha);
	HRESULT SnappingToEdge( WINDOWPOS * lpWindowPos );
	HRESULT LoadDllsRuntime();
	HRESULT RegisterAvatarMenu();  // TODO move to CLC class
	HRESULT CreateCluiFrames();
	HRESULT CreateCLCWindow(const HWND parent);
	HRESULT CreateUIFrames();

	LRESULT DefCluiWndProc( UINT msg, WPARAM wParam, LPARAM lParam )
	{
		return corecli.pfnContactListWndProc( m_hWnd, msg, wParam, lParam );
	}

	// MessageMap
	LRESULT PreProcessWndProc( UINT msg, WPARAM wParam, LPARAM lParam, BOOL& bHandled );
	LRESULT OnSizingMoving( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnThemeChanged( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnDwmCompositionChanged( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnSyncCall( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnUpdate( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnInitMenu( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnNcPaint( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnEraseBkgnd( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnNcCreate( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnPaint( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnCreate( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnSetAllExtraIcons( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnCreateClc( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnLButtonDown( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnParentNotify( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnSetFocus( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnTimer( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnStatusBarUpdateTimer( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnAutoAlphaTimer( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnSmoothAlphaTransitionTimer( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnDelayedSizingTimer( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnBringOutTimer( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnBringInTimer( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnUpdateBringTimer( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnActivate( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnSetCursor( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnMouseActivate( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnNcLButtonDown( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnNcLButtonDblClk( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnNcHitTest( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnShowWindow( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnSysCommand( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnKeyDown( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnGetMinMaxInfo( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnMoving( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnNotify( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnListSizeChangeNotify( NMCLISTCONTROL * pnmc );
	LRESULT OnClickNotify( NMCLISTCONTROL * pnmc );
	LRESULT OnContextMenu( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnMeasureItem( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnDrawItem( UINT msg, WPARAM wParam, LPARAM lParam );
	LRESULT OnDestroy( UINT msg, WPARAM wParam, LPARAM lParam );

protected:
	HMODULE m_hDwmapiDll;
	HMODULE m_hUserDll;

	enum { SNAPTOEDGESENSIVITY = 30 };
};

#endif // modern_clui_h__