-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCandidateListUIPresenter.h
143 lines (113 loc) · 5.38 KB
/
CandidateListUIPresenter.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
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
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved
#pragma once
#include "Private.h"
#include "SampleIME.h"
#include "CandidateWindow.h"
#include "CompositionProcessorEngine.h"
#include "SampleIMEBaseStructure.h"
#include "KeyHandlerEditSession.h"
#include "TfTextLayoutSink.h"
class CReadingLine;
//+---------------------------------------------------------------------------
//
// CCandidateListUIPresenter
//
// ITfCandidateListUIElement / ITfIntegratableCandidateListUIElement is used for
// UILess mode support
// ITfCandidateListUIElementBehavior sends the Selection behavior message to
// 3rd party IME.
//----------------------------------------------------------------------------
class CCandidateListUIPresenter : public CTfTextLayoutSink,
public ITfCandidateListUIElementBehavior,
public ITfIntegratableCandidateListUIElement
{
public:
CCandidateListUIPresenter(_In_ CSampleIME *pTextService, ATOM atom, KEYSTROKE_CATEGORY Category,
_In_ CCandidateRange *pIndexRange, BOOL hideWindow);
virtual ~CCandidateListUIPresenter();
// IUnknown
STDMETHODIMP QueryInterface(REFIID riid, _Outptr_ void **ppvObj);
STDMETHODIMP_(ULONG) AddRef(void);
STDMETHODIMP_(ULONG) Release(void);
// ITfUIElement
STDMETHODIMP GetDescription(BSTR *pbstr);
STDMETHODIMP GetGUID(GUID *pguid);
STDMETHODIMP Show(BOOL showCandidateWindow);
STDMETHODIMP IsShown(BOOL *pIsShow);
// ITfCandidateListUIElement
STDMETHODIMP GetUpdatedFlags(DWORD *pdwFlags);
STDMETHODIMP GetDocumentMgr(ITfDocumentMgr **ppdim);
STDMETHODIMP GetCount(UINT *pCandidateCount);
STDMETHODIMP GetSelection(UINT *pSelectedCandidateIndex);
STDMETHODIMP GetString(UINT uIndex, BSTR *pbstr);
STDMETHODIMP GetPageIndex(UINT *pIndex, UINT uSize, UINT *puPageCnt);
STDMETHODIMP SetPageIndex(UINT *pIndex, UINT uPageCnt);
STDMETHODIMP GetCurrentPage(UINT *puPage);
// ITfCandidateListUIElementBehavior methods
STDMETHODIMP SetSelection(UINT nIndex);
STDMETHODIMP Finalize(void);
STDMETHODIMP Abort(void);
// ITfIntegratableCandidateListUIElement
STDMETHODIMP SetIntegrationStyle(GUID guidIntegrationStyle);
STDMETHODIMP GetSelectionStyle(_Out_ TfIntegratableCandidateListSelectionStyle *ptfSelectionStyle);
STDMETHODIMP OnKeyDown(_In_ WPARAM wParam, _In_ LPARAM lParam, _Out_ BOOL *pIsEaten);
STDMETHODIMP ShowCandidateNumbers(_Out_ BOOL *pIsShow);
STDMETHODIMP FinalizeExactCompositionString();
virtual HRESULT _StartCandidateList(TfClientId tfClientId, _In_ ITfDocumentMgr *pDocumentMgr,
_In_ ITfContext *pContextDocument, TfEditCookie ec,
_In_ ITfRange *pRangeComposition, UINT wndWidth);
void _EndCandidateList();
void _SetText(_In_ CSampleImeArray<CCandidateListItem> *pCandidateList, BOOL isAddFindKeyCode);
void _ClearList();
VOID _SetTextColor(COLORREF crColor, COLORREF crBkColor);
VOID _SetFillColor(HBRUSH hBrush);
DWORD_PTR _GetSelectedCandidateString(_Outptr_result_maybenull_ const WCHAR **ppwchCandidateString);
BOOL _SetSelectionInPage(int nPos)
{
return _pCandidateWnd->_SetSelectionInPage(nPos);
}
BOOL _MoveSelection(_In_ int offSet);
BOOL _SetSelection(_In_ int selectedIndex);
BOOL _MovePage(_In_ int offSet);
void _MoveWindowToTextExt();
// CTfTextLayoutSink
virtual VOID _LayoutChangeNotification(_In_ RECT *lpRect);
virtual VOID _LayoutDestroyNotification();
// Event for ITfThreadFocusSink
virtual HRESULT OnSetThreadFocus();
virtual HRESULT OnKillThreadFocus();
void RemoveSpecificCandidateFromList(_In_ LCID Locale, _Inout_ CSampleImeArray<CCandidateListItem> &candidateList,
_In_ CStringRange &srgCandidateString);
void AdviseUIChangedByArrowKey(_In_ KEYSTROKE_FUNCTION arrowKey);
private:
virtual HRESULT CALLBACK _CandidateChangeNotification(_In_ enum CANDWND_ACTION action);
static HRESULT _CandWndCallback(_In_ void *pv, _In_ enum CANDWND_ACTION action);
friend COLORREF _AdjustTextColor(_In_ COLORREF crColor, _In_ COLORREF crBkColor);
HRESULT _UpdateUIElement();
HRESULT ToShowCandidateWindow();
HRESULT ToHideCandidateWindow();
HRESULT BeginUIElement();
HRESULT EndUIElement();
HRESULT MakeCandidateWindow(_In_ ITfContext *pContextDocument, _In_ UINT wndWidth);
void DisposeCandidateWindow();
void AddCandidateToCandidateListUI(_In_ CSampleImeArray<CCandidateListItem> *pCandidateList, BOOL isAddFindKeyCode);
void SetPageIndexWithScrollInfo(_In_ CSampleImeArray<CCandidateListItem> *pCandidateList);
protected:
CCandidateWindow *_pCandidateWnd;
BOOL _isShowMode;
BOOL _hideWindow;
private:
HWND _parentWndHandle;
ATOM _atom;
CCandidateRange *_pIndexRange;
KEYSTROKE_CATEGORY _Category;
DWORD _updatedFlags;
DWORD _uiElementId;
CSampleIME *_pTextService;
LONG _refCount;
};