satok | 8fbd552 | 2011-02-22 17:28:55 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef LATINIME_PROXIMITY_INFO_H |
| 18 | #define LATINIME_PROXIMITY_INFO_H |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | |
| 22 | #include "defines.h" |
| 23 | |
| 24 | namespace latinime { |
| 25 | |
satok | cfca3c6 | 2011-08-10 14:30:10 +0900 | [diff] [blame] | 26 | class Correction; |
satok | 2df3060 | 2011-07-15 13:49:00 +0900 | [diff] [blame] | 27 | |
satok | 8fbd552 | 2011-02-22 17:28:55 +0900 | [diff] [blame] | 28 | class ProximityInfo { |
| 29 | public: |
satok | d24df43 | 2011-07-14 15:43:42 +0900 | [diff] [blame] | 30 | typedef enum { // Used as a return value for character comparison |
| 31 | SAME_OR_ACCENTED_OR_CAPITALIZED_CHAR, // Same char, possibly with different case or accent |
| 32 | NEAR_PROXIMITY_CHAR, // It is a char located nearby on the keyboard |
| 33 | UNRELATED_CHAR // It is an unrelated char |
| 34 | } ProximityType; |
| 35 | |
satok | 817e517 | 2011-03-04 06:06:45 -0800 | [diff] [blame] | 36 | ProximityInfo(const int maxProximityCharsSize, const int keyboardWidth, |
| 37 | const int keybaordHeight, const int gridWidth, const int gridHeight, |
| 38 | const uint32_t *proximityCharsArray); |
satok | 8fbd552 | 2011-02-22 17:28:55 +0900 | [diff] [blame] | 39 | ~ProximityInfo(); |
satok | 817e517 | 2011-03-04 06:06:45 -0800 | [diff] [blame] | 40 | bool hasSpaceProximity(const int x, const int y) const; |
satok | 1d7eaf8 | 2011-07-13 10:32:02 +0900 | [diff] [blame] | 41 | void setInputParams(const int* inputCodes, const int inputLength); |
| 42 | const int* getProximityCharsAt(const int index) const; |
satok | d24df43 | 2011-07-14 15:43:42 +0900 | [diff] [blame] | 43 | unsigned short getPrimaryCharAt(const int index) const; |
| 44 | bool existsCharInProximityAt(const int index, const int c) const; |
| 45 | bool existsAdjacentProximityChars(const int index) const; |
| 46 | ProximityType getMatchedProximityId( |
satok | 985312e | 2011-08-05 21:21:01 +0900 | [diff] [blame] | 47 | const int index, const unsigned short c, const bool checkProximityChars) const; |
satok | 1d7eaf8 | 2011-07-13 10:32:02 +0900 | [diff] [blame] | 48 | bool sameAsTyped(const unsigned short *word, int length) const; |
satok | 0cedd2b | 2011-08-12 01:05:27 +0900 | [diff] [blame] | 49 | const unsigned short* getPrimaryInputWord() const { |
| 50 | return mPrimaryInputWord; |
| 51 | } |
satok | 635f68e | 2011-08-10 22:19:33 +0900 | [diff] [blame] | 52 | |
satok | 8fbd552 | 2011-02-22 17:28:55 +0900 | [diff] [blame] | 53 | private: |
satok | 817e517 | 2011-03-04 06:06:45 -0800 | [diff] [blame] | 54 | int getStartIndexFromCoordinates(const int x, const int y) const; |
Ken Wakasa | de3070a | 2011-03-19 09:16:42 +0900 | [diff] [blame] | 55 | const int MAX_PROXIMITY_CHARS_SIZE; |
satok | 817e517 | 2011-03-04 06:06:45 -0800 | [diff] [blame] | 56 | const int KEYBOARD_WIDTH; |
| 57 | const int KEYBOARD_HEIGHT; |
satok | 8fbd552 | 2011-02-22 17:28:55 +0900 | [diff] [blame] | 58 | const int GRID_WIDTH; |
| 59 | const int GRID_HEIGHT; |
Ken Wakasa | de3070a | 2011-03-19 09:16:42 +0900 | [diff] [blame] | 60 | const int CELL_WIDTH; |
| 61 | const int CELL_HEIGHT; |
satok | 1d7eaf8 | 2011-07-13 10:32:02 +0900 | [diff] [blame] | 62 | const int *mInputCodes; |
satok | 8fbd552 | 2011-02-22 17:28:55 +0900 | [diff] [blame] | 63 | uint32_t *mProximityCharsArray; |
satok | 1d7eaf8 | 2011-07-13 10:32:02 +0900 | [diff] [blame] | 64 | int mInputLength; |
satok | 0cedd2b | 2011-08-12 01:05:27 +0900 | [diff] [blame] | 65 | unsigned short mPrimaryInputWord[MAX_WORD_LENGTH_INTERNAL]; |
satok | 8fbd552 | 2011-02-22 17:28:55 +0900 | [diff] [blame] | 66 | }; |
Ken Wakasa | ce9e52a | 2011-06-18 13:09:55 +0900 | [diff] [blame] | 67 | |
| 68 | } // namespace latinime |
| 69 | |
satok | 8fbd552 | 2011-02-22 17:28:55 +0900 | [diff] [blame] | 70 | #endif // LATINIME_PROXIMITY_INFO_H |