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_MODERN_VIEW_H 39 0 yongsun #define SUNPY_IMI_MODERN_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 CIMIModernView : public CIMIView { 46 0 yongsun public: 47 0 yongsun CIMIModernView(); 48 0 yongsun 49 0 yongsun virtual ~CIMIModernView(); 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 void setStatusAttrValue(int key, int value); 60 0 yongsun 61 0 yongsun virtual int onKeyEvent(unsigned keycode, unsigned keyvalue, unsigned modifier); 62 122 tonylee 63 122 tonylee virtual int onCandidatePageRequest(int pgno, bool relative); 64 118 tonylee 65 118 tonylee virtual int onCandidateSelectRequest(int index); 66 0 yongsun 67 0 yongsun virtual void getPreeditString(IPreeditString& ps); 68 0 yongsun 69 0 yongsun virtual void getCandidateList(ICandidateList& cl, int start, int size); 70 0 yongsun 71 0 yongsun protected: 72 0 yongsun /** 73 0 yongsun * cancel current editing syllable, ie., If the syllable is waiting to 74 0 yongsun * be inserted to the skeleton as a new bone, clear it. If the syllable 75 0 yongsun * is used to modifying a existing bone of the skeleton, unshadow the bone. 76 0 yongsun * After this, we enter sentence editing mode. So, both PREEDIT_MASK and 77 0 yongsun * CANDIDATE_MASK should be set. 78 0 yongsun */ 79 0 yongsun void 80 0 yongsun cancelSyllable(unsigned int& mask); 81 0 yongsun 82 0 yongsun /** 83 0 yongsun * commit the current editing syllable PINYIN string[0..len). Only 84 0 yongsun * when current syllable[0..len) is valid and m_SyllableStr[len..) is 85 0 yongsun * non-complete or valid. After commit, m_SyllableStr[len..) become the 86 0 yongsun * new value of current syllable string. 87 0 yongsun * @param len: m_SyllableStr[0..len) is to be inserted into skeleton 88 0 yongsun * as a valid PINYIN syllable. 89 0 yongsun * @param boundaryType: AUOT_BOUNDARY or USER_BOUNDARY here. Specify the 90 0 yongsun * boundary type for the bone to be inserted 91 0 yongsun * @param mask: whether or not the windows should be redraw\n 92 0 yongsun */ 93 0 yongsun void 94 0 yongsun convertSyllable(int boundaryType, int len, unsigned int& mask); 95 0 yongsun /*@}*/ 96 0 yongsun 97 0 yongsun 98 0 yongsun /** 99 0 yongsun * Select the idx-th candidate on user's request. move the current 100 0 yongsun * Bone forwards to next bone, re-get candidate list. So, all 101 0 yongsun * window area (preedit and candidate window) should be update 102 0 yongsun */ 103 0 yongsun void 104 0 yongsun makeSelection(int idx, unsigned int& mask); 105 0 yongsun 106 0 yongsun 107 0 yongsun /*@{*/ 108 0 yongsun /** 109 0 yongsun * for simplicity. call m_pIC->modify do most of the work, 110 0 yongsun * put the current bone ptr right behind what erased. so do for 111 0 yongsun * current candi bone ptr. Put the new m_SyllBone to the position 112 0 yongsun * right after boneIt. 113 0 yongsun * @param boneIt: the bone to be deleted 114 0 yongsun * @param mask whether or not the candi is re-got 115 0 yongsun */ 116 0 yongsun void 117 0 yongsun eraseBone(CSkeletonIter boneIt, unsigned int& mask); 118 0 yongsun 119 0 yongsun /** 120 0 yongsun * insert a Punc or Simbol bone into the skeleton at current position. 121 0 yongsun * The core should provide better fast support for this. 122 0 yongsun * @param bone: the bone to be added 123 0 yongsun * @return whether or not the candidate list is re-got 124 0 yongsun */ 125 0 yongsun void 126 0 yongsun insertNonPinyinBone(CBone& bone, unsigned int& mask); 127 0 yongsun /*@}*/ 128 0 yongsun 129 0 yongsun /*@{*/ 130 0 yongsun /** 131 0 yongsun * commit whole sentence to user. 132 0 yongsun * @return combination of the area update mask bits 133 0 yongsun */ 134 0 yongsun unsigned 135 287 yongsun doCommit(bool bConvert=true); 136 0 yongsun 137 0 yongsun /** commit sentence at the left side of the m_SyllBone to user */ 138 0 yongsun void 139 0 yongsun tryCommitLeftSentence(unsigned int& mask); 140 0 yongsun 141 0 yongsun /** commit single character to user, only when skeleton is empty */ 142 0 yongsun void 143 0 yongsun commitChar(TWCHAR ch); 144 0 yongsun 145 0 yongsun /** 146 0 yongsun * get best sentence 147 0 yongsun * @param pSyllPos to return the starting position for current syllable 148 0 yongsun * @param pSyllSize to return the size of current syllable 149 0 yongsun * @return the caret position of the char 150 0 yongsun */ 151 0 yongsun int 152 0 yongsun getSentence(wstring& wstr, int* pSyllPos=NULL, int* pSyllSize=NULL); 153 0 yongsun /*@}*/ 154 0 yongsun 155 0 yongsun /*@{*/ 156 0 yongsun /** 157 0 yongsun * Process key when we are in syllable editing mode, ie, 158 0 yongsun * the m_SyllableStr is not zero. 159 0 yongsun */ 160 0 yongsun void 161 0 yongsun pressKeyOnSyllable(unsigned keycode, unsigned keyvalue, unsigned modifier, unsigned int& mask); 162 0 yongsun 163 0 yongsun /** 164 0 yongsun * Process key when we are in sentence editing mode, ie, 165 0 yongsun * the m_SyllableStr is zero length. 166 0 yongsun */ 167 0 yongsun void 168 0 yongsun pressKeyOnSentence(unsigned keycode, unsigned keyvalue, unsigned modifier, unsigned int& mask); 169 0 yongsun 170 0 yongsun /** 171 0 yongsun * Process non-pinyin character input when we are in sentence 172 0 yongsun * editing mode, ie, the m_SyllableStr is zero length. for those 173 0 yongsun * non-printable character, return it back to IM System as we do 174 0 yongsun * not accept the event (make no change to mask). 175 0 yongsun * First, we map Punc and Simbol, and when IC is empty, commit the 176 0 yongsun * mapped char. When IC has some content, make a bone and insert 177 0 yongsun * it into the skeleton. 178 0 yongsun */ 179 0 yongsun void 180 0 yongsun pressNormalKey(unsigned keycode, unsigned keyvalue, unsigned modifier, unsigned int& mask); 181 0 yongsun /*@}*/ 182 0 yongsun 183 0 yongsun protected: 184 0 yongsun /*@{*/ 185 0 yongsun /** 186 0 yongsun * The syllable value we are now editing upon m_curBone. 187 0 yongsun * Note, that when it is not zero lengthed, whether or not 188 0 yongsun * EN state can be switched into, or whether or not non-pinyin 189 0 yongsun * char could be input should be considered carefully. By the 190 0 yongsun * way, the caret is always positioned at the tail of this string. 191 0 yongsun */ 192 0 yongsun wstring m_SyllableStr; 193 0 yongsun 194 0 yongsun /** Whether the Syllable is from a existing bone, or new to be inserted */ 195 0 yongsun bool m_bNewSyll; 196 0 yongsun 197 0 yongsun /** 198 0 yongsun * Current Syllable which the caret is just before or upon. this is 199 0 yongsun * also the candidate-list's starting bone. 200 0 yongsun */ 201 0 yongsun CSkeletonIter m_SyllBone; 202 0 yongsun 203 0 yongsun /** the candidate list */ 204 0 yongsun CCandidates m_CandiList; 205 0 yongsun 206 0 yongsun /** the index in whole list of first candidate shown in the candidate bar */ 207 0 yongsun int m_CandiFirst; 208 0 yongsun 209 140 tonylee /** cursor position inside the current syllable we are now editing */ 210 140 tonylee int m_CursorIdx; 211 140 tonylee 212 0 yongsun /*@}*/ 213 0 yongsun 214 0 yongsun }; 215 0 yongsun 216 0 yongsun #endif 217