ReactOS 0.4.15-dev-7998-gdb93cb1
CLangBarItemList Class Reference
Inheritance diagram for CLangBarItemList:
Collaboration diagram for CLangBarItemList:

Public Member Functions

BOOL IsStartedIntentionally (REFCLSID rclsid)
 
LANGBARITEMSTATEAddItem (REFCLSID rclsid)
 
void Clear ()
 
BOOL SetDemoteLevel (REFCLSID rclsid, DWORD dwDemoteLevel)
 
LANGBARITEMSTATEFindItem (REFCLSID rclsid)
 
LANGBARITEMSTATEGetItemStateFromTimerId (UINT_PTR nTimerID)
 
void Load ()
 
void SaveItem (CicRegKey *pRegKey, const LANGBARITEMSTATE *pState)
 
void StartDemotingTimer (REFCLSID rclsid, BOOL bIntentional)
 
UINT_PTR FindDemotingTimerId ()
 
- Public Member Functions inherited from CicArray< LANGBARITEMSTATE >
 CicArray ()
 
LANGBARITEMSTATEdata () const
 
size_t size () const
 
bool empty () const
 
void clear ()
 
LANGBARITEMSTATEoperator[] (size_t iItem)
 
const LANGBARITEMSTATEoperator[] (size_t iItem) const
 
LANGBARITEMSTATEAppend (size_t cGrow)
 
BOOL Add (const LANGBARITEMSTATE &item)
 
ptrdiff_t Find (const LANGBARITEMSTATE &item) const
 
BOOL Insert (size_t iItem, size_t cGrow)
 
void Remove (size_t iItem, size_t cRemove=1)
 

Additional Inherited Members

- Protected Member Functions inherited from CicArrayBase
 CicArrayBase (size_t cbItem)
 
virtual ~CicArrayBase ()
 
BOOL Insert (size_t iItem, size_t cGrow)
 
LPVOID Append (size_t cGrow)
 
void Remove (size_t iItem, size_t cRemove=1)
 
- Protected Attributes inherited from CicArrayBase
LPBYTE m_pb
 
size_t m_cItems
 
size_t m_cbItem
 
size_t m_cCapacity
 

Detailed Description

Definition at line 1080 of file msutb.cpp.

Member Function Documentation

◆ AddItem()

LANGBARITEMSTATE * CLangBarItemList::AddItem ( REFCLSID  rclsid)

Definition at line 3931 of file msutb.cpp.

3932{
3933 auto *pItem = FindItem(rclsid);
3934 if (pItem)
3935 return pItem;
3936
3937 pItem = Append(1);
3938 if (!pItem)
3939 return NULL;
3940
3941 ZeroMemory(pItem, sizeof(*pItem));
3942 pItem->m_clsid = rclsid;
3943 pItem->m_dwDemoteLevel = 0;
3944 return pItem;
3945}
LANGBARITEMSTATE * FindItem(REFCLSID rclsid)
Definition: msutb.cpp:3981
LANGBARITEMSTATE * Append(size_t cGrow)
Definition: cicarray.h:52
#define NULL
Definition: types.h:112
#define ZeroMemory
Definition: winbase.h:1712

◆ Clear()

void CLangBarItemList::Clear ( )

Definition at line 3947 of file msutb.cpp.

3948{
3949 clear();
3950
3951 CicRegKey regKey;
3952 LSTATUS error;
3953 error = regKey.Open(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\CTF\\LangBar", KEY_ALL_ACCESS);
3954 if (error == ERROR_SUCCESS)
3955 regKey.RecurseDeleteKey(L"ItemState");
3956}
LSTATUS Open(HKEY hKey, LPCTSTR lpSubKey, REGSAM samDesired=KEY_READ)
Definition: cicreg.h:51
LSTATUS RecurseDeleteKey(LPCTSTR lpSubKey)
Definition: cicreg.h:113
#define ERROR_SUCCESS
Definition: deptool.c:10
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
#define error(str)
Definition: mkdosfs.c:1605
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define L(x)
Definition: ntvdm.h:50
#define HKEY_CURRENT_USER
Definition: winreg.h:11

Referenced by CTipbarWnd::ClearLBItemList().

◆ FindDemotingTimerId()

UINT_PTR CLangBarItemList::FindDemotingTimerId ( )

Definition at line 4118 of file msutb.cpp.

4119{
4120 UINT_PTR nTimerID = 10000;
4121
4122 if (empty())
4123 return nTimerID;
4124
4125 for (;;)
4126 {
4127 size_t iItem = 0;
4128
4129 while ((*this)[iItem].m_nTimerID != nTimerID)
4130 {
4131 ++iItem;
4132 if (iItem >= size())
4133 return nTimerID;
4134 }
4135
4136 ++nTimerID;
4137 if (nTimerID >= 10050)
4138 return 0;
4139 }
4140}
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274

Referenced by StartDemotingTimer().

◆ FindItem()

LANGBARITEMSTATE * CLangBarItemList::FindItem ( REFCLSID  rclsid)

Definition at line 3981 of file msutb.cpp.

3982{
3983 for (size_t iItem = 0; iItem < size(); ++iItem)
3984 {
3985 auto& item = (*this)[iItem];
3986 if (IsEqualCLSID(item.m_clsid, rclsid))
3987 return &item;
3988 }
3989 return NULL;
3990}
static ATOM item
Definition: dde.c:856
#define IsEqualCLSID(rclsid1, rclsid2)
Definition: guiddef.h:96

Referenced by AddItem(), and IsStartedIntentionally().

◆ GetItemStateFromTimerId()

LANGBARITEMSTATE * CLangBarItemList::GetItemStateFromTimerId ( UINT_PTR  nTimerID)

Definition at line 3992 of file msutb.cpp.

3993{
3994 for (size_t iItem = 0; iItem < size(); ++iItem)
3995 {
3996 auto& item = (*this)[iItem];
3997 if (item.m_nTimerID == nTimerID)
3998 return &item;
3999 }
4000 return NULL;
4001}

◆ IsStartedIntentionally()

BOOL CLangBarItemList::IsStartedIntentionally ( REFCLSID  rclsid)

Definition at line 3923 of file msutb.cpp.

3924{
3925 auto *pItem = FindItem(rclsid);
3926 if (!pItem)
3927 return FALSE;
3928 return pItem->m_bStartedIntentionally;
3929}
#define FALSE
Definition: types.h:117

◆ Load()

void CLangBarItemList::Load ( )

Definition at line 4003 of file msutb.cpp.

4004{
4005 CicRegKey regKey;
4006 LSTATUS error;
4007 error = regKey.Open(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\CTF\\LangBar\\ItemState");
4008 if (error != ERROR_SUCCESS)
4009 return;
4010
4011 WCHAR szKeyName[MAX_PATH];
4012 for (DWORD dwIndex = 0; ; ++dwIndex)
4013 {
4014 error = ::RegEnumKeyW(regKey, dwIndex, szKeyName, _countof(szKeyName));
4015 if (error != ERROR_SUCCESS)
4016 break;
4017
4018 CLSID clsid;
4019 if (::CLSIDFromString(szKeyName, &clsid) != S_OK)
4020 continue;
4021
4022 CicRegKey regKey2;
4023 error = regKey2.Open(regKey, szKeyName);
4024 if (error != ERROR_SUCCESS)
4025 continue;
4026
4027 auto *pItem = AddItem(clsid);
4028 if (!pItem)
4029 continue;
4030
4031 DWORD Data = 0;
4032 regKey2.QueryDword(L"DemoteLevel", &Data);
4033 pItem->m_dwDemoteLevel = Data;
4034 regKey2.QueryDword(L"DisableDemoting", &Data);
4035 pItem->m_bDisableDemoting = !!Data;
4036 }
4037}
LSTATUS QueryDword(LPCTSTR pszValueName, LPDWORD pdwValue)
Definition: cicreg.h:61
LONG WINAPI RegEnumKeyW(HKEY hKey, DWORD dwIndex, LPWSTR lpName, DWORD cbName)
Definition: reg.c:2393
#define MAX_PATH
Definition: compat.h:34
HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id)
Definition: compobj.c:2338
unsigned long DWORD
Definition: ntddk_ex.h:95
#define S_OK
Definition: intsafe.h:52
REFCLSID clsid
Definition: msctf.c:82
#define _countof(array)
Definition: sndvol32.h:68
#define AddItem
Definition: userenv.h:209
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ SaveItem()

void CLangBarItemList::SaveItem ( CicRegKey pRegKey,
const LANGBARITEMSTATE pState 
)

Definition at line 4039 of file msutb.cpp.

4040{
4041 LSTATUS error;
4042 CicRegKey regKey;
4043
4044 if (!pRegKey)
4045 {
4046 error = regKey.Create(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\CTF\\LangBar\\ItemState");
4047 if (error != ERROR_SUCCESS)
4048 return;
4049
4050 pRegKey = &regKey;
4051 }
4052
4053 WCHAR szSubKey[MAX_PATH];
4054 ::StringFromGUID2(pState->m_clsid, szSubKey, _countof(szSubKey));
4055
4056 if (pState->m_dwDemoteLevel || pState->m_bDisableDemoting)
4057 {
4058 CicRegKey regKey2;
4059 error = regKey2.Create(*pRegKey, szSubKey);
4060 if (error == ERROR_SUCCESS)
4061 {
4062 DWORD dwDemoteLevel = pState->m_dwDemoteLevel;
4063 if (dwDemoteLevel)
4064 regKey2.SetDword(L"DemoteLevel", dwDemoteLevel);
4065 else
4066 regKey2.DeleteValue(L"DemoteLevel");
4067
4068 regKey2.SetDword(L"DisableDemoting", pState->m_bDisableDemoting);
4069 }
4070 }
4071 else
4072 {
4073 pRegKey->RecurseDeleteKey(szSubKey);
4074 }
4075}
LSTATUS DeleteValue(LPCTSTR pszValueName)
Definition: cicreg.h:98
LSTATUS SetDword(LPCTSTR pszValueName, DWORD dwValue)
Definition: cicreg.h:67
LSTATUS Create(HKEY hKey, LPCTSTR lpSubKey)
Definition: cicreg.h:56
INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax)
Definition: compobj.c:2434
DWORD m_dwDemoteLevel
Definition: msutb.cpp:17
BOOL m_bDisableDemoting
Definition: msutb.cpp:21
CLSID m_clsid
Definition: msutb.cpp:16

Referenced by SetDemoteLevel().

◆ SetDemoteLevel()

BOOL CLangBarItemList::SetDemoteLevel ( REFCLSID  rclsid,
DWORD  dwDemoteLevel 
)

Definition at line 3958 of file msutb.cpp.

3959{
3960 auto *pItem = AddItem(rclsid);
3961 if (!pItem)
3962 return TRUE;
3963
3964 pItem->m_dwDemoteLevel = dwDemoteLevel;
3965 if (!pItem->IsShown())
3966 {
3967 if (pItem->m_nTimerID)
3968 {
3969 if (g_pTipbarWnd)
3970 g_pTipbarWnd->KillTimer(pItem->m_nTimerID);
3971 pItem->m_nTimerID = 0;
3972 pItem->m_uTimeOut = 0;
3973 }
3974 pItem->m_bDisableDemoting = FALSE;
3975 }
3976
3977 SaveItem(0, pItem);
3978 return TRUE;
3979}
void SaveItem(CicRegKey *pRegKey, const LANGBARITEMSTATE *pState)
Definition: msutb.cpp:4039
BOOL KillTimer(UINT_PTR uIDEvent)
Definition: msutb.cpp:4714
#define TRUE
Definition: types.h:120
CTipbarWnd * g_pTipbarWnd
Definition: msutb.cpp:104

◆ StartDemotingTimer()

void CLangBarItemList::StartDemotingTimer ( REFCLSID  rclsid,
BOOL  bIntentional 
)

Definition at line 4077 of file msutb.cpp.

4078{
4079 if (!g_bIntelliSense)
4080 return;
4081
4082 auto *pItem = AddItem(rclsid);
4083 if (!pItem || pItem->m_bDisableDemoting)
4084 return;
4085
4086 if (pItem->m_nTimerID)
4087 {
4088 if (!bIntentional)
4089 return;
4090
4091 if (g_pTipbarWnd)
4092 g_pTipbarWnd->KillTimer(pItem->m_nTimerID);
4093
4094 pItem->m_nTimerID = 0;
4095 }
4096
4097 pItem->m_bStartedIntentionally |= bIntentional;
4098
4099 UINT uTimeOut = (bIntentional ? g_uTimeOutIntentional : g_uTimeOutNonIntentional);
4100 pItem->m_uTimeOut += uTimeOut;
4101
4102 if (pItem->m_uTimeOut < g_uTimeOutMax)
4103 {
4104 UINT_PTR uDemotingTimerId = FindDemotingTimerId();
4105 pItem->m_nTimerID = uDemotingTimerId;
4106 if (uDemotingTimerId)
4107 {
4108 if (g_pTipbarWnd)
4109 g_pTipbarWnd->SetTimer(uDemotingTimerId, uTimeOut);
4110 }
4111 }
4112 else
4113 {
4114 pItem->m_bDisableDemoting = TRUE;
4115 }
4116}
UINT_PTR FindDemotingTimerId()
Definition: msutb.cpp:4118
UINT_PTR SetTimer(UINT_PTR nIDEvent, UINT uElapse)
Definition: msutb.cpp:4707
UINT g_uTimeOutIntentional
Definition: msutb.cpp:51
BOOL g_bIntelliSense
Definition: msutb.cpp:48
UINT g_uTimeOutNonIntentional
Definition: msutb.cpp:50
UINT g_uTimeOutMax
Definition: msutb.cpp:52
unsigned int UINT
Definition: ndis.h:50

The documentation for this class was generated from the following file: