-
Notifications
You must be signed in to change notification settings - Fork 0
/
Globals.h
168 lines (136 loc) · 4.64 KB
/
Globals.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
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
// 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
#ifndef UNICODE
#define UNICODE
#endif
#include "private.h"
#include "define.h"
#include "SampleIMEBaseStructure.h"
void DllAddRef();
void DllRelease();
namespace Global
{
//---------------------------------------------------------------------
// inline
//---------------------------------------------------------------------
inline void SafeRelease(_In_ IUnknown *punk)
{
if (punk != nullptr)
{
punk->Release();
}
}
inline void QuickVariantInit(_Inout_ VARIANT *pvar)
{
pvar->vt = VT_EMPTY;
}
inline void QuickVariantClear(_Inout_ VARIANT *pvar)
{
switch (pvar->vt)
{
// some ovbious VTs that don't need to call VariantClear.
case VT_EMPTY:
case VT_NULL:
case VT_I2:
case VT_I4:
case VT_R4:
case VT_R8:
case VT_CY:
case VT_DATE:
case VT_I1:
case VT_UI1:
case VT_UI2:
case VT_UI4:
case VT_I8:
case VT_UI8:
case VT_INT:
case VT_UINT:
case VT_BOOL:
break;
// Call release for VT_UNKNOWN.
case VT_UNKNOWN:
SafeRelease(pvar->punkVal);
break;
default:
// we call OleAut32 for other VTs.
VariantClear(pvar);
break;
}
pvar->vt = VT_EMPTY;
}
//+---------------------------------------------------------------------------
//
// IsTooSimilar
//
// Return TRUE if the colors cr1 and cr2 are so similar that they
// are hard to distinguish. Used for deciding to use reverse video
// selection instead of system selection colors.
//
//----------------------------------------------------------------------------
inline BOOL IsTooSimilar(COLORREF cr1, COLORREF cr2)
{
if ((cr1 | cr2) & 0xFF000000) // One color and/or the other isn't RGB, so algorithm doesn't apply
{
return FALSE;
}
LONG DeltaR = abs(GetRValue(cr1) - GetRValue(cr2));
LONG DeltaG = abs(GetGValue(cr1) - GetGValue(cr2));
LONG DeltaB = abs(GetBValue(cr1) - GetBValue(cr2));
return DeltaR + DeltaG + DeltaB < 80;
}
//---------------------------------------------------------------------
// extern
//---------------------------------------------------------------------
extern HINSTANCE dllInstanceHandle;
extern ATOM AtomCandidateWindow;
extern ATOM AtomShadowWindow;
extern ATOM AtomScrollBarWindow;
BOOL RegisterWindowClass();
extern LONG dllRefCount;
extern CRITICAL_SECTION CS;
extern HFONT defaultlFontHandle; // Global font object we use everywhere
extern const CLSID SampleIMECLSID;
extern const CLSID SampleIMEGuidProfile;
extern const CLSID SampleIMEGuidImeModePreserveKey;
extern const CLSID SampleIMEGuidDoubleSingleBytePreserveKey;
extern const CLSID SampleIMEGuidPunctuationPreserveKey;
LRESULT CALLBACK ThreadKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam);
BOOL CheckModifiers(UINT uModCurrent, UINT uMod);
BOOL UpdateModifiers(WPARAM wParam, LPARAM lParam);
void LogMessage(const char* message);
void LogMessageW(const wchar_t* message);
extern USHORT ModifiersValue;
extern BOOL IsShiftKeyDownOnly;
extern BOOL IsControlKeyDownOnly;
extern BOOL IsAltKeyDownOnly;
extern const GUID SampleIMEGuidCompartmentDoubleSingleByte;
extern const GUID SampleIMEGuidCompartmentPunctuation;
extern const WCHAR FullWidthCharTable[];
extern const struct _PUNCTUATION PunctuationTable[14];
extern const GUID SampleIMEGuidLangBarIMEMode;
extern const GUID SampleIMEGuidLangBarDoubleSingleByte;
extern const GUID SampleIMEGuidLangBarPunctuation;
extern const GUID SampleIMEGuidDisplayAttributeInput;
extern const GUID SampleIMEGuidDisplayAttributeConverted;
extern const GUID SampleIMEGuidCandUIElement;
extern const WCHAR UnicodeByteOrderMark;
extern const WCHAR KeywordDelimiter;
extern const WCHAR StringDelimiter;
extern const WCHAR ImeModeDescription[];
extern const int ImeModeOnIcoIndex;
extern const int ImeModeOffIcoIndex;
extern const WCHAR DoubleSingleByteDescription[];
extern const int DoubleSingleByteOnIcoIndex;
extern const int DoubleSingleByteOffIcoIndex;
extern const WCHAR PunctuationDescription[];
extern const int PunctuationOnIcoIndex;
extern const int PunctuationOffIcoIndex;
extern const WCHAR LangbarImeModeDescription[];
extern const WCHAR LangbarDoubleSingleByteDescription[];
extern const WCHAR LangbarPunctuationDescription[];
} // namespace Global