IMECandidate.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /******************************************************************************
  19. *
  20. * FILE
  21. * $Archive: /Commando/Code/wwui/IMECandidate.h $
  22. *
  23. * DESCRIPTION
  24. *
  25. * PROGRAMMER
  26. * $Author: Denzil_l $
  27. *
  28. * VERSION INFO
  29. * $Revision: 4 $
  30. * $Modtime: 1/11/02 6:44p $
  31. *
  32. ******************************************************************************/
  33. #ifndef __IMECANDIDATE_H__
  34. #define __IMECANDIDATE_H__
  35. #include "Notify.h"
  36. #include "win.h"
  37. #include <imm.h>
  38. #pragma warning(disable : 4514)
  39. #if defined(_MSC_VER)
  40. #pragma warning(push, 3)
  41. #endif
  42. #include <vector>
  43. #if defined(_MSC_VER)
  44. #pragma warning(pop)
  45. #endif
  46. namespace IME {
  47. class IMECandidate
  48. {
  49. public:
  50. IMECandidate();
  51. ~IMECandidate();
  52. void Open(int index, HWND hwnd, UINT codepage, bool unicode, bool startFrom1);
  53. void Read(void);
  54. void Close(void);
  55. bool IsValid(void) const;
  56. int GetIndex(void) const;
  57. unsigned long GetStyle(void) const;
  58. // Get the index of the first candidate in the page
  59. unsigned long GetPageStart(void) const;
  60. // Set the page to start with the specified candidate index
  61. void SetPageStart(unsigned long);
  62. // Get the number of candidates per page
  63. unsigned long GetPageSize(void) const;
  64. // Get the total number of candidates in the list.
  65. unsigned long GetCount(void) const;
  66. // Get the index of the current candidate selection
  67. unsigned long GetSelection(void) const;
  68. // Get the specified candidate string
  69. const wchar_t* GetCandidate(unsigned long index);
  70. // Select a candidate from the list.
  71. void SelectCandidate(unsigned long index);
  72. // Set the candidate page view
  73. void SetView(unsigned long topIndex, unsigned long bottomIndex);
  74. // Check if the candidates should be displayed starting from 1 or 0
  75. bool IsStartFrom1(void) const;
  76. private:
  77. int mIndex;
  78. HWND mHWND;
  79. UINT mCodePage;
  80. bool mUseUnicode;
  81. bool mStartFrom1;
  82. unsigned long mCandidateSize;
  83. CANDIDATELIST* mCandidates;
  84. // Multibyte -> Unicode string conversion buffer
  85. wchar_t mTempString[80];
  86. };
  87. typedef enum
  88. {
  89. CANDIDATE_OPEN = 1,
  90. CANDIDATE_CHANGE,
  91. CANDIDATE_CLOSE
  92. } CandidateAction;
  93. typedef TypedActionPtr<CandidateAction, IMECandidate> CandidateEvent;
  94. typedef std::vector<IMECandidate> IMECandidateCollection;
  95. } // namespace IME
  96. #endif // __IMECANDIDATE_H__