Blender  V2.93
GHOST_ImeWin32.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (c) 2010 The Chromium Authors. All rights reserved.
17  * All rights reserved.
18  *
19  * The Original Code is: some of this file.
20  */
21 
26 #pragma once
27 
28 #ifdef WITH_INPUT_IME
29 
30 # define WIN32_LEAN_AND_MEAN
31 # include <windows.h>
32 
33 # include <string>
34 
35 # include "GHOST_Event.h"
36 # include "GHOST_Rect.h"
37 # include <vector>
38 
39 class GHOST_EventIME : public GHOST_Event {
40  public:
47  GHOST_EventIME(GHOST_TUns64 msec, GHOST_TEventType type, GHOST_IWindow *window, void *customdata)
48  : GHOST_Event(msec, type, window)
49  {
50  this->m_data = customdata;
51  }
52 };
53 
95 /* This struct represents the status of an ongoing composition. */
96 struct ImeComposition {
97  /* Represents the cursor position in the IME composition. */
98  int cursor_position;
99 
100  /* Represents the position of the beginning of the selection */
101  int target_start;
102 
103  /* Represents the position of the end of the selection */
104  int target_end;
105 
114  int string_type;
115 
116  /* Represents the string retrieved from IME (Input Method Editor) */
117  std::wstring ime_string;
118  std::vector<char> utf8_buf;
119  std::vector<unsigned char> format;
120 };
121 
138 class GHOST_ImeWin32 {
139  public:
140  GHOST_ImeWin32();
141  ~GHOST_ImeWin32();
142 
143  /* Retrieves whether or not there is an ongoing composition. */
144  bool is_composing() const
145  {
146  return is_composing_;
147  }
148 
157  bool SetInputLanguage();
158 
165  void CreateImeWindow(HWND window_handle);
166 
187  void SetImeWindowStyle(
188  HWND window_handle, UINT message, WPARAM wparam, LPARAM lparam, BOOL *handled);
189 
196  void DestroyImeWindow(HWND window_handle);
197 
204  void UpdateImeWindow(HWND window_handle);
205 
213  void CleanupComposition(HWND window_handle);
214 
223  void ResetComposition(HWND window_handle);
224 
246  bool GetResult(HWND window_handle, LPARAM lparam, ImeComposition *composition);
247 
269  bool GetComposition(HWND window_handle, LPARAM lparam, ImeComposition *composition);
270 
293  void BeginIME(HWND window_handle, const GHOST_Rect &caret_rect, bool complete);
294 
304  void EndIME(HWND window_handle);
305 
307  void UpdateInfo(HWND window_handle);
308 
310  void CheckFirst(HWND window_handle);
311 
312  ImeComposition resultInfo, compInfo;
313  GHOST_TEventImeData eventImeData;
314 
315  protected:
316  /* Determines whether or not the given attribute represents a target (a.k.a. a selection). */
317  bool IsTargetAttribute(char attribute) const
318  {
319  return (attribute == ATTR_TARGET_CONVERTED || attribute == ATTR_TARGET_NOTCONVERTED);
320  }
321 
322  /* Retrieve the target area. */
323  void GetCaret(HIMC imm_context, LPARAM lparam, ImeComposition *composition);
324 
325  /* Update the position of the IME windows. */
326  void MoveImeWindow(HWND window_handle, HIMC imm_context);
327 
328  /* Complete the ongoing composition if it exists. */
329  void CompleteComposition(HWND window_handle, HIMC imm_context);
330 
331  /* Retrieve a string from the IMM. */
332  bool GetString(HIMC imm_context, WPARAM lparam, int type, ImeComposition *composition);
333 
334  private:
339  bool is_composing_;
340 
348  bool ime_status_;
349 
372  LANGID input_language_id_;
373 
380  bool system_caret_;
381 
382  /* The rectangle of the input caret retrieved from a renderer process. */
383  GHOST_Rect caret_rect_;
384 
385  /* used for disable ime when start up */
386  bool is_first, is_enable;
387 };
388 
389 #endif // WITH_INPUT_IME
unsigned long long GHOST_TUns64
Definition: GHOST_Types.h:86
GHOST_TEventType
Definition: GHOST_Types.h:177
typedef UINT
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
btAlignedObjectArray< btScalar > m_data
format
Definition: logImageCore.h:47