spiegel-keyman/windows/src/support/tsf-tip-standalone-test/candidatewindow.cpp
Marc Durdin b65b982584 Keyman Desktop and Keyman Developer open source 10.0 alpha seed (#121)
* Keyman for Windows 10.0 Open Source

* Squashed 'windows/src/ext/jedi/jedi/' content from commit f444ad2

git-subtree-dir: windows/src/ext/jedi/jedi
git-subtree-split: f444ad2da4693851e523f1ea6bd541f701904c24

* Squashed 'windows/src/ext/jedi/jcl/' content from commit d63d3c9fd

git-subtree-dir: windows/src/ext/jedi/jcl
git-subtree-split: d63d3c9fd9ff84efdd8159084ec6a60313644243

* Squashed 'windows/src/ext/jedi/jvcl/' content from commit bee19f3b4

git-subtree-dir: windows/src/ext/jedi/jvcl
git-subtree-split: bee19f3b46909fde2fa92c06cd2706f41d99f6c3

* Add required .res files

* Add required .res files

* Add docbook files (forced)

* Add required libxslt

* Add required jedi files

* Add installation files

* Tweak .gitignore for open

* CI

* Remove KMW from Developer source (#122)

* Remove KMW from Developer source (copies during build)

* Remove KMW from Developer source (copies during build)

* Remove KMW from Developer source (copies during build)

* Fixup release build and copy license, readme from kmw during build

* Remove obsolete build help documentation

* Keyman Engine 10 on Windows regression for shift states (#129)

* Improve #128 -- cleaner debug messages

* Fixes #127, shift state now resets correctly; and more work for #128

* Fixes #130 (#131)
2017-07-25 10:53:06 +07:00

208 lines
5.1 KiB
C++

//////////////////////////////////////////////////////////////////////
//
// 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) 2003 Microsoft Corporation. All rights reserved.
//
// CandidateWindow.cpp
//
// CCandidateWindow class
//
//////////////////////////////////////////////////////////////////////
#include "Globals.h"
#include "TextService.h"
#include "CandidateWindow.h"
#define CAND_WIDTH 200
#define CAND_HEIGHT 50
ATOM CCandidateWindow::_atomWndClass = 0;
const TCHAR c_szCandidateDescription[] = TEXT("Dummy Candidate Window");
//+---------------------------------------------------------------------------
//
// ctor
//
//----------------------------------------------------------------------------
CCandidateWindow::CCandidateWindow()
{
_hwnd = NULL;
}
//+---------------------------------------------------------------------------
//
// _InitWindowClass
//
//----------------------------------------------------------------------------
/* static */
BOOL CCandidateWindow::_InitWindowClass()
{
WNDCLASS wc;
wc.style = 0;
wc.lpfnWndProc = CCandidateWindow::_WindowProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = g_hInst;
wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = TEXT("TextServiceCandidateWindow");
_atomWndClass = RegisterClass(&wc);
return (_atomWndClass != 0);
}
//+---------------------------------------------------------------------------
//
// _UninitClass
//
//----------------------------------------------------------------------------
/* static */
void CCandidateWindow::_UninitWindowClass()
{
if (_atomWndClass != 0)
{
UnregisterClass((LPCTSTR)_atomWndClass, g_hInst);
}
}
//+---------------------------------------------------------------------------
//
// _Create
//
//----------------------------------------------------------------------------
BOOL CCandidateWindow::_Create()
{
_hwnd = CreateWindowEx(WS_EX_TOPMOST | WS_EX_TOOLWINDOW,
(LPCTSTR)_atomWndClass,
TEXT("TextService Candidate Window"),
WS_BORDER | WS_DISABLED | WS_POPUP,
0, 0,
CAND_WIDTH, CAND_HEIGHT,
NULL,
NULL,
g_hInst,
this);
return (_hwnd != NULL);
}
//+---------------------------------------------------------------------------
//
// _Destroy
//
//----------------------------------------------------------------------------
void CCandidateWindow::_Destroy()
{
if (_hwnd != NULL)
{
DestroyWindow(_hwnd);
_hwnd = NULL;
}
}
//+---------------------------------------------------------------------------
//
// _Move
//
//----------------------------------------------------------------------------
void CCandidateWindow::_Move(int x, int y)
{
if (_hwnd != NULL)
{
RECT rc;
GetWindowRect(_hwnd, &rc);
MoveWindow(_hwnd, x, y, rc.right - rc.left, rc.bottom - rc.top, TRUE);
}
}
//+---------------------------------------------------------------------------
//
// _Show
//
//----------------------------------------------------------------------------
void CCandidateWindow::_Show()
{
ShowWindow(_hwnd, SW_SHOWNA);
}
//+---------------------------------------------------------------------------
//
// _Hide
//
//----------------------------------------------------------------------------
void CCandidateWindow::_Hide()
{
ShowWindow(_hwnd, SW_HIDE);
}
//+---------------------------------------------------------------------------
//
// _OnKeyDown
//
//----------------------------------------------------------------------------
HRESULT CCandidateWindow::_OnKeyDown(UINT uVKey)
{
return S_OK;
}
//+---------------------------------------------------------------------------
//
// _OnKeyUp
//
//----------------------------------------------------------------------------
HRESULT CCandidateWindow::_OnKeyUp(UINT uVKey)
{
return S_OK;
}
//+---------------------------------------------------------------------------
//
// _WindowProc
//
// Cand window proc.
//----------------------------------------------------------------------------
/* static */
LRESULT CALLBACK CCandidateWindow::_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
switch (uMsg)
{
case WM_CREATE:
_SetThis(hwnd, lParam);
return 0;
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
SetBkMode(hdc, TRANSPARENT);
TextOut(hdc, 0, 0, c_szCandidateDescription, lstrlen(c_szCandidateDescription));
EndPaint(hwnd, &ps);
return 0;
}
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}