forked from EasyIME/libIME
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LangBarButton.h
118 lines (93 loc) · 3.06 KB
/
LangBarButton.h
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
//
// Copyright (C) 2013 Hong Jen Yee (PCMan) <[email protected]>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library 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
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the
// Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
// Boston, MA 02110-1301, USA.
//
#ifndef IME_LANGUAGE_BAR_BUTTON_H
#define IME_LANGUAGE_BAR_BUTTON_H
#include <msctf.h>
#include <string.h>
#include <Windows.h>
#include <map>
#include <string>
namespace Ime {
class TextService;
class LangBarButton:
public ITfLangBarItemButton,
public ITfSource {
public:
LangBarButton(TextService* service, const GUID& guid, UINT commandId = 0, const wchar_t* text = NULL, DWORD style = TF_LBI_STYLE_BTN_BUTTON);
// public methods
const wchar_t* text() const;
void setText(const wchar_t* text);
void setText(UINT stringId);
const wchar_t* tooltip() const;
void setTooltip(const wchar_t* tooltip);
void setTooltip(UINT stringId);
HICON icon() const;
void setIcon(HICON icon);
void setIcon(UINT iconId);
UINT commandId() const;
void setCommandId(UINT id);
HMENU menu() const;
void setMenu(HMENU menu);
bool enabled() const;
void setEnabled(bool enable);
// need to create the button with TF_LBI_STYLE_BTN_TOGGLE style
bool toggled() const;
void setToggled(bool toggle);
DWORD style() const;
void setStyle(DWORD style);
// COM-related stuff
// IUnknown
STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj);
STDMETHODIMP_(ULONG) AddRef(void);
STDMETHODIMP_(ULONG) Release(void);
// ITfLangBarItem
STDMETHODIMP GetInfo(TF_LANGBARITEMINFO *pInfo);
STDMETHODIMP GetStatus(DWORD *pdwStatus);
STDMETHODIMP Show(BOOL fShow);
STDMETHODIMP GetTooltipString(BSTR *pbstrToolTip);
// ITfLangBarItemButton
STDMETHODIMP OnClick(TfLBIClick click, POINT pt, const RECT *prcArea);
STDMETHODIMP InitMenu(ITfMenu *pMenu);
STDMETHODIMP OnMenuSelect(UINT wID);
STDMETHODIMP GetIcon(HICON *phIcon);
STDMETHODIMP GetText(BSTR *pbstrText);
// ITfSource
STDMETHODIMP AdviseSink(REFIID riid, IUnknown *punk, DWORD *pdwCookie);
STDMETHODIMP UnadviseSink(DWORD dwCookie);
void update(DWORD flags = TF_LBI_BTNALL);
TextService* textService() const {
return textService_;
};
protected: // COM object should not be deleted directly. calling Release() instead.
virtual ~LangBarButton(void);
private:
void buildITfMenu(ITfMenu* menu, HMENU templ);
private:
int refCount_;
TextService* textService_;
TF_LANGBARITEMINFO info_;
UINT commandId_;
std::wstring tooltip_;
HICON icon_;
HMENU menu_;
std::map<DWORD, ITfLangBarItemSink*> sinks_;
DWORD status_;
};
}
#endif