summaryrefslogtreecommitdiff
path: root/plugins/TopToolBar/src/stdafx.h
blob: b8d387cfde9da8b0d0f3199314232b26baeae426 (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
#ifndef TTB_COMMON_H
#define TTB_COMMON_H

#include <windows.h>
#include <commctrl.h>
#include <stddef.h>

#include <win2k.h>
#include <newpluginapi.h>
#include <m_database.h>
#include <m_skin.h>
#include <m_clistint.h>
#include <m_cluiframes.h>
#include <m_clc.h>
#include <m_findadd.h>
#include <m_langpack.h>
#include <m_options.h>
#include <m_button.h>
#include <m_icolib.h>

#include <m_toptoolbar.h>

#include "resource.h"
#include "version.h"
#include "BkgrCfg.h"

#define TTB_BUTTON_CLASS  L"TopToolbarButtonClass"

#define TTB_REPOSBUTTONS          (WM_USER+10)
#define TTB_UPDATEFRAMEVISIBILITY (WM_USER+11)

#define TTBDEFAULT_BKBMPUSE      CLB_STRETCH
#define TTBDEFAULT_BKCOLOUR      GetSysColor(COLOR_3DFACE)
#define TTBDEFAULT_USEBITMAP     0
#define TTBDEFAULT_SELBKCOLOUR   GetSysColor(COLOR_HIGHLIGHT)

#define TTBBF_INTERNAL 0x1000000
#define TTBBF_OPTIONAL 0x2000000

struct CMPlugin : public PLUGIN<CMPlugin>
{
	CMPlugin() :
		PLUGIN<CMPlugin>(TTB_OPTDIR)
	{}
};

///////////////////////////////////////////////////////////////////////////////
// TopButtonInt class

struct TopButtonInt : public MZeroedObject
{
	~TopButtonInt();

	DWORD CheckFlags(DWORD Flags);
	void  CreateWnd(void);
	void  LoadSettings(void);
	void  SaveSettings(int *SepCnt, int *LaunchCnt);
	void  SetBitmap(void);

	__inline bool isSep() const
	{	return (dwFlags & TTBBF_ISSEPARATOR) != 0;
	}

	__inline bool isVisible() const
	{	return (dwFlags & TTBBF_VISIBLE) != 0;
	}

	HWND   hwnd;
	int    id;
	BOOL   bPushed;
	int    dwFlags;
	int    x, y, arrangedpos;
	HICON  hIconUp, hIconDn;
	HANDLE hIconHandleUp, hIconHandleDn;

	char  *pszService;
	wchar_t *ptszProgram;
	char  *pszName;
	wchar_t *ptszTooltip;

	LPARAM lParamUp;
	WPARAM wParamUp;
	LPARAM lParamDown;
	WPARAM wParamDown;

	int    hLangpack;
	wchar_t *ptszTooltipUp, *ptszTooltipDn;
};

///////////////////////////////////////////////////////////////////////////////

int TTBOptInit(WPARAM wParam, LPARAM lParam);
//append string
char __inline *AS(char *str, const char *setting, char *addstr);

TopButtonInt* CreateButton(TTBButton* but);

int LoadBackgroundOptions();

int ArrangeButtons();

#define DEFBUTTWIDTH	20
#define DEFBUTTHEIGHT	20
#define DEFBUTTGAP		1

#define SEPWIDTH		3

extern TTBCtrl* g_ctrl;

extern LIST<TopButtonInt> Buttons;
extern HBITMAP hBmpBackground;
extern mir_cs csButtonsHook;
extern pfnCustomProc g_CustomProc;
extern LPARAM g_CustomProcParam;
extern HANDLE hTTBModuleLoaded;
extern IconItem iconList[];

void AddToOptions(TopButtonInt* b);
void RemoveFromOptions(int id);

//append string
char *AS(char *str, const char *setting, char *addstr)
{
	if (str != nullptr) {
		mir_strcpy(str, setting);
		mir_strcat(str, addstr);
	}
	return str;
}

#define TTB_LAUNCHSERVICE "TTB/LaunchService"

TopButtonInt* idtopos(int id, int* pPos = nullptr);

INT_PTR TTBAddButton(WPARAM, LPARAM);
INT_PTR TTBRemoveButton(WPARAM, LPARAM);

void InitInternalButtons(void);

int  LoadToolbarModule(void);
int  UnloadToolbarModule(void);

int  SaveAllButtonsOptions(void);

void LoadAllSeparators();
void LoadAllLButs();

#endif