Merge branch 'ime-control'

Provide some control over IME and use it to fix wxGrid when using IME.

See #27026.
This commit is contained in:
Vadim Zeitlin
2026-09-25 00:05:20 +02:00
15 changed files with 575 additions and 36 deletions
+4
View File
@@ -3223,6 +3223,10 @@ private:
// the edit control is shown, but just supposes that it is.
void DoSaveEditControlValue();
// Update the state of the IME when anything affecting it changed.
void UpdateIME();
// these sets contain the indices of fixed, i.e. non-resizable
// interactively, grid rows or columns and are null if there are no fixed
// elements (which is the default)
+4
View File
@@ -427,6 +427,10 @@ public:
wxGridWindowType GetType() const { return m_type; }
// Update the position of the input method windows to correspond to the
// current cell.
void UpdateIMECursorRect();
private:
const wxGridWindowType m_type;
+5
View File
@@ -339,6 +339,9 @@ public:
// "commit" signal handler.
bool GTKDoInsertTextFromIM(const char* text);
// Actual implementation of DoUpdateInputMethodCursorRect().
void GTKUpdateIMCursorRect(GtkIMContext* imContext) const;
// indices for the arrays below
enum ScrollDir { ScrollDir_Horz, ScrollDir_Vert, ScrollDir_Max };
@@ -416,6 +419,8 @@ protected:
virtual void DoSetClientSize(int width, int height) override;
virtual void DoMoveWindow(int x, int y, int width, int height) override;
virtual void DoEnable(bool enable) override;
virtual void DoEnableInputMethod(bool enable) override;
virtual void DoUpdateInputMethodCursorRect() override;
#if wxUSE_MENUS_NATIVE
virtual bool DoPopupMenu( wxMenu *menu, int x, int y ) override;
+1
View File
@@ -688,6 +688,7 @@ protected:
virtual void DoReleaseMouse() override;
virtual void DoEnable(bool enable) override;
virtual void DoEnableInputMethod(bool enable) override;
virtual void DoFreeze() override;
virtual void DoThaw() override;
+39
View File
@@ -1304,6 +1304,27 @@ public:
wxCaret *GetCaret() const { return m_caret; }
#endif // wxUSE_CARET
// input method (IME) support
// --------------------------
// enable or disable input method for this window, it's enabled by
// default but can be disabled for windows not accepting text input
void EnableInputMethod(bool enable = true);
bool IsInputMethodEnabled() const { return m_enableIME; }
// set the rectangle, in client coordinates, where the text is being
// input: the input method windows are positioned near it
//
// this must be called by the windows accepting text input whenever
// this rectangle changes, e.g. because the insertion point moved or
// the window was scrolled
void UpdateInputMethodCursorRect(const wxRect& rect);
// return the rectangle set by the function above for this window, or
// an empty rectangle, meaning that the input method default position
// is used, if it wasn't set for it
wxRect GetInputMethodCursorRect() const;
// get the (average) character size for the current font
virtual int GetCharHeight() const = 0;
virtual int GetCharWidth() const = 0;
@@ -1799,6 +1820,15 @@ protected:
// widgets state are necessary
virtual void DoEnable(bool WXUNUSED(enable)) { }
// this method should be implemented to really enable or disable input
// method for this window, it's only called if the state changes
virtual void DoEnableInputMethod(bool WXUNUSED(enable)) { }
// this method can be implemented to really update the input method
// windows position, using GetInputMethodCursorRect(), it's only called if
// the input method is enabled
virtual void DoUpdateInputMethodCursorRect() { }
// the window id - a number which uniquely identifies a window among
// its siblings unless it is wxID_ANY
@@ -1890,6 +1920,9 @@ protected:
bool m_disableFocusFromKbd:1;
bool m_enableFocusFromKbd:1;
// flag controlling the use of IME (enabled by default)
bool m_enableIME:1;
// window attributes
long m_windowStyle,
m_exStyle;
@@ -2077,6 +2110,12 @@ private:
// (i.e. not being updated) if it is positive
unsigned int m_freezeCount;
// The window for which the input method cursor rectangle was set and the
// rectangle itself: as only the window having the focus can use it, we
// don't need to store it in every window.
static const wxWindowBase* ms_imeCursorWindow;
static wxRect ms_imeCursorRect;
wxDECLARE_ABSTRACT_CLASS(wxWindowBase);
wxDECLARE_NO_COPY_CLASS(wxWindowBase);
wxDECLARE_EVENT_TABLE();