1 0 yongsun /* 2 82 yongsun * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 82 yongsun * 4 82 yongsun * Copyright (c) 2007 Sun Microsystems, Inc. All Rights Reserved. 5 82 yongsun * 6 82 yongsun * The contents of this file are subject to the terms of either the GNU Lesser 7 82 yongsun * General Public License Version 2.1 only ("LGPL") or the Common Development and 8 82 yongsun * Distribution License ("CDDL")(collectively, the "License"). You may not use this 9 82 yongsun * file except in compliance with the License. You can obtain a copy of the CDDL at 10 82 yongsun * http://www.opensource.org/licenses/cddl1.php and a copy of the LGPLv2.1 at 11 82 yongsun * http://www.opensource.org/licenses/lgpl-license.php. See the License for the 12 82 yongsun * specific language governing permissions and limitations under the License. When 13 82 yongsun * distributing the software, include this License Header Notice in each file and 14 82 yongsun * include the full text of the License in the License file as well as the 15 82 yongsun * following notice: 16 82 yongsun * 17 82 yongsun * NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND DISTRIBUTION LICENSE 18 82 yongsun * (CDDL) 19 82 yongsun * For Covered Software in this distribution, this License shall be governed by the 20 82 yongsun * laws of the State of California (excluding conflict-of-law provisions). 21 82 yongsun * Any litigation relating to this License shall be subject to the jurisdiction of 22 82 yongsun * the Federal Courts of the Northern District of California and the state courts 23 82 yongsun * of the State of California, with venue lying in Santa Clara County, California. 24 82 yongsun * 25 82 yongsun * Contributor(s): 26 82 yongsun * 27 82 yongsun * If you wish your version of this file to be governed by only the CDDL or only 28 82 yongsun * the LGPL Version 2.1, indicate your decision by adding "[Contributor]" elects to 29 82 yongsun * include this software in this distribution under the [CDDL or LGPL Version 2.1] 30 82 yongsun * license." If you don't indicate a single choice of license, a recipient has the 31 82 yongsun * option to distribute your version of this file under either the CDDL or the LGPL 32 82 yongsun * Version 2.1, or to extend the choice of license to its licensees as provided 33 82 yongsun * above. However, if you add LGPL Version 2.1 code and therefore, elected the LGPL 34 82 yongsun * Version 2 license, then the option applies only if the new code is made subject 35 82 yongsun * to such option by the copyright holder. 36 0 yongsun */ 37 82 yongsun 38 0 yongsun #ifndef SUNPY_IMI_CLASSIC_VIEW_H 39 0 yongsun #define SUNPY_IMI_CLASSIC_VIEW_H 40 0 yongsun 41 0 yongsun #include "portability.h" 42 0 yongsun 43 0 yongsun #include "imi_view.h" 44 0 yongsun 45 0 yongsun class CIMIClassicView : public CIMIView { 46 0 yongsun public: 47 0 yongsun CIMIClassicView(); 48 0 yongsun 49 0 yongsun virtual ~CIMIClassicView(); 50 0 yongsun 51 0 yongsun virtual int getViewType(void); 52 0 yongsun 53 0 yongsun virtual void attachIC(CIMIContext* pIC); 54 0 yongsun 55 0 yongsun virtual unsigned clearIC(void); 56 0 yongsun 57 0 yongsun virtual void updateWindows(unsigned int mask); 58 0 yongsun 59 0 yongsun virtual int onKeyEvent(unsigned keycode, unsigned keyvalue, unsigned modifier); 60 0 yongsun 61 0 yongsun virtual int onCandidatePageRequest(int pgno, bool relative); 62 0 yongsun 63 0 yongsun virtual int onCandidateSelectRequest(int index); 64 0 yongsun 65 0 yongsun /*@{*/ 66 0 yongsun /** 67 0 yongsun * get preedit, where from the beginning of the skeleton to the m_candiBone, 68 0 yongsun * give the best converted HANZI string. from the m_candiBone (include) to 69 0 yongsun * the end of the skeleton, give the original PINYIN string. 70 0 yongsun */ 71 0 yongsun virtual void getPreeditString(IPreeditString& ps); 72 0 yongsun 73 0 yongsun virtual void getCandidateList(ICandidateList& cl, int start, int size); 74 0 yongsun /*@}*/ 75 0 yongsun 76 0 yongsun 77 0 yongsun protected: 78 0 yongsun void 79 0 yongsun pressNormalKey(unsigned keyvalue, unsigned int& mask); 80 0 yongsun 81 0 yongsun /** 82 0 yongsun * Select the idx-th candidate on user's request. move the current 83 0 yongsun * Bone forwards to next bone, re-get candidate list. So, all 84 0 yongsun * window area (preedit and candidate window) should be update 85 0 yongsun */ 86 0 yongsun void 87 0 yongsun makeSelection(int idx, unsigned int& mask); 88 0 yongsun 89 0 yongsun 90 0 yongsun /*@{*/ 91 0 yongsun /** 92 39 ys148558 * Note only left direction move would cause human selection be discarded 93 0 yongsun * @return: the leftmost bone iterator after operation from which 94 0 yongsun * the new search should begin. If searchAgain = false, 95 0 yongsun * should call explictly to: 96 0 yongsun * m_pIC->searchFrom(leftmost) 97 0 yongsun * value m_pIC->getLastBone() indicat no search are needed or done! 98 0 yongsun */ 99 0 yongsun CSkeletonIter 100 0 yongsun moveLeft(unsigned int& mask, bool searchAgain=true); 101 0 yongsun 102 0 yongsun CSkeletonIter 103 0 yongsun moveLeftSyllable(unsigned int& mask, bool searchAgain=true); 104 0 yongsun 105 0 yongsun CSkeletonIter 106 0 yongsun moveHome(unsigned int& mask, bool searchAgain=true); 107 0 yongsun 108 0 yongsun void 109 0 yongsun moveRight(unsigned int& mask); 110 0 yongsun 111 0 yongsun void 112 0 yongsun moveRightSyllable(unsigned int& mask); 113 0 yongsun 114 0 yongsun void 115 0 yongsun moveEnd(unsigned int& mask); 116 0 yongsun /*@}*/ 117 0 yongsun 118 0 yongsun /*@{*/ 119 0 yongsun /** 120 0 yongsun * Erase a character near current cursor on the preedit area 121 0 yongsun * @param bLeft: true to erase left char beside cursor. 122 0 yongsun * false to erase right char beside cursor. 123 0 yongsun * @param mask: which area should be update after this operation. 124 0 yongsun */ 125 0 yongsun void 126 0 yongsun erase(bool bLeft, unsigned int& mask); 127 0 yongsun 128 0 yongsun /** 129 0 yongsun * Insert a Pinyin character right before the cursor. 130 0 yongsun * @param keyvalue: the Pinyin Char to be inserted before cursor. 131 0 yongsun * @param mask: which area should be update after this operation. 132 0 yongsun */ 133 0 yongsun void 134 0 yongsun insertPinyin(unsigned int keyvalue, unsigned int& mask); 135 0 yongsun 136 0 yongsun /** 137 0 yongsun * Insert a normal character at the cursor. 138 0 yongsun * @param boneType: NODE_ASCII or NODE_PUNC 139 0 yongsun * @param keyvalue: the normal char to be inserted, must in [0x20,0x7e]. 140 0 yongsun * @param mask : which area should be update after this operation. 141 0 yongsun */ 142 0 yongsun void 143 0 yongsun insertNormalChar(int boneType, unsigned orig_value, unsigned keyvalue, unsigned int& mask); 144 0 yongsun 145 0 yongsun /** 146 0 yongsun * Insert human boundary to current cursor on the preedit area, or change 147 0 yongsun * the old boundary at cursor from auto boundary to human boundary. 148 0 yongsun * @param mask: which area should be update after this operation. 149 0 yongsun */ 150 0 yongsun void 151 0 yongsun insertBoundary(unsigned int& mask); 152 0 yongsun /*@}*/ 153 0 yongsun 154 0 yongsun /*@{*/ 155 0 yongsun /** 156 0 yongsun * commit whole sentence to user. 157 0 yongsun * @param bConvert: true to commit the converted HANZI string. 158 0 yongsun * false to commit the unconverted PINYIN string. 159 0 yongsun */ 160 0 yongsun void 161 0 yongsun doCommit(bool bConvert=true); 162 0 yongsun 163 0 yongsun /** commit single character to user, only when skeleton is empty */ 164 0 yongsun void 165 0 yongsun commitChar(TWCHAR ch); 166 0 yongsun 167 0 yongsun /** 168 0 yongsun * get best sentence from itStart to the end of the skeleton. 169 0 yongsun * @param itStart: the starting bone from which convertion starts 170 0 yongsun * @param wstr: the HANZI string of the convertion 171 0 yongsun * @return : the number of converted words in the wstr string.(ie. do not count 172 0 yongsun * non-pinyin node's result. 173 0 yongsun */ 174 0 yongsun int 175 0 yongsun getSentence(wstring& wstr, CSkeletonIter itStart); 176 0 yongsun /*@}*/ 177 0 yongsun 178 0 yongsun private: 179 0 yongsun /** the bone under the cursor */ 180 0 yongsun CSkeletonIter m_CursorBone; 181 0 yongsun 182 0 yongsun /** cursor position inside the bone */ 183 0 yongsun int m_CursorIdx; 184 0 yongsun 185 0 yongsun /** the candidate-list's starting bone. */ 186 0 yongsun CSkeletonIter m_CandiBone; 187 0 yongsun 188 0 yongsun /** the candidate list */ 189 0 yongsun CCandidates m_CandiList; 190 0 yongsun 191 0 yongsun /** the index in whole list of first candidate shown in the candidate bar */ 192 0 yongsun int m_CandiFirst; 193 0 yongsun 194 0 yongsun /** tail sentence starting from m_CandiFirst */ 195 0 yongsun wstring m_TailSentence; 196 0 yongsun 197 0 yongsun private: 198 0 yongsun void 199 0 yongsun getCandidates(); 200 0 yongsun 201 0 yongsun bool 202 0 yongsun cursorAtTail(); 203 0 yongsun }; 204 0 yongsun 205 0 yongsun #endif 206