llpreeditor.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /**
  2. * @file llpreeditor.h
  3. * @brief I believe this is used for languages like Japanese that require
  4. * an "input method editor" to type Kanji.
  5. * @author Open source patch, incorporated by Dave Simmons
  6. *
  7. * $LicenseInfo:firstyear=2007&license=viewergpl$
  8. *
  9. * Copyright (c) 2007-2009, Linden Research, Inc.
  10. *
  11. * Second Life Viewer Source Code
  12. * The source code in this file ("Source Code") is provided by Linden Lab
  13. * to you under the terms of the GNU General Public License, version 2.0
  14. * ("GPL"), unless you have obtained a separate licensing agreement
  15. * ("Other License"), formally executed by you and Linden Lab. Terms of
  16. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  17. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  18. *
  19. * There are special exceptions to the terms and conditions of the GPL as
  20. * it is applied to this Source Code. View the full text of the exception
  21. * in the file doc/FLOSS-exception.txt in this software distribution, or
  22. * online at
  23. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  24. *
  25. * By copying, modifying or distributing this software, you acknowledge
  26. * that you have read and understood your obligations described above,
  27. * and agree to abide by those obligations.
  28. *
  29. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  30. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  31. * COMPLETENESS OR PERFORMANCE.
  32. * $/LicenseInfo$
  33. */
  34. #ifndef LL_PREEDITOR
  35. #define LL_PREEDITOR
  36. #include <vector>
  37. #include "llrect.h"
  38. class LLCoordGL;
  39. class LLPreeditor
  40. {
  41. public:
  42. typedef std::vector<S32> segment_lengths_t;
  43. #if LL_DARWIN
  44. // Darwin's clang does not know how to convert vector<int> to vector<bool> !
  45. typedef std::vector<S32> standouts_t;
  46. #else
  47. typedef std::vector<bool> standouts_t;
  48. #endif
  49. // We do not delete against LLPreeditor, but compilers complain without
  50. // this...
  51. virtual ~LLPreeditor() {}
  52. // Discard any preedit info. on this preeditor.
  53. virtual void resetPreedit() = 0;
  54. // Update the preedit feedback using specified details.
  55. // Existing preedit is discarded and replaced with the new one (i.e.
  56. // updatePreedit is not cumulative).
  57. // All arguments are IN.
  58. // preedit_count is the number of elements in arrays preedit_list and
  59. // preedit_standouts.
  60. // preedit list is an array of preedit texts (clauses.)
  61. // preedit_standouts indicates whether each preedit text should be shown as
  62. // standout clause.
  63. // caret_position is the preedit-local position of text editing caret, in #
  64. // of llwchar.
  65. virtual void updatePreedit(const LLWString& preedit_string,
  66. const segment_lengths_t& preedit_seg_lengths,
  67. const standouts_t& preedit_standouts,
  68. S32 caret_position) = 0;
  69. // Turn the specified sub-contents into an active preedit.
  70. // Both position and length are IN and count with UTF-32 (llwchar)
  71. // characters. This method primarily facilitates reconversion.
  72. virtual void markAsPreedit(S32 position, S32 length) = 0;
  73. // Get the position and the length of the active preedit in the contents.
  74. // Both position and length are OUT and count with UTF-32 (llwchar)
  75. // characters. When this preeditor has no active preedit, position
  76. // receives the caret position, and length receives 0.
  77. virtual void getPreeditRange(S32* position, S32* length) const = 0;
  78. // Get the position and the length of the current selection in the contents.
  79. // Both position and length are OUT and count with UTF-32 (llwchar)
  80. // characters. When this preeditor has no selection, position receives
  81. // the caret position, and length receives 0.
  82. virtual void getSelectionRange(S32* position, S32* length) const = 0;
  83. // Get the locations where the preedit and related UI elements are
  84. // displayed. Locations are relative to the app window and measured in GL
  85. // coordinate space (before scaling). query_position is IN argument, and
  86. // other three are OUT.
  87. virtual bool getPreeditLocation(S32 query_position, LLCoordGL* coord,
  88. LLRect* bounds, LLRect* control) const = 0;
  89. // Get the size (height) of the current font used in this preeditor.
  90. virtual S32 getPreeditFontSize() const = 0;
  91. // Get the contents of this preeditor as a LLWString. If there is an active
  92. // preedit, the returned LLWString contains it.
  93. virtual const LLWString& getWText() const = 0;
  94. // Handle a UTF-32 char on this preeditor, i.e., add the character to the
  95. // contents. This is a back door of the method of same name of
  96. // LLWindowCallback.
  97. virtual bool handleUnicodeCharHere(llwchar uni_char) = 0;
  98. };
  99. #endif