src/hbcore/inputfw/hbinputstate.h
changeset 0 16d8024aca5e
child 1 f7ac710697a9
equal deleted inserted replaced
-1:000000000000 0:16d8024aca5e
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (developer.feedback@nokia.com)
       
     6 **
       
     7 ** This file is part of the HbCore module of the UI Extensions for Mobile.
       
     8 **
       
     9 ** GNU Lesser General Public License Usage
       
    10 ** This file may be used under the terms of the GNU Lesser General Public
       
    11 ** License version 2.1 as published by the Free Software Foundation and
       
    12 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
       
    13 ** Please review the following information to ensure the GNU Lesser General
       
    14 ** Public License version 2.1 requirements will be met:
       
    15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    16 **
       
    17 ** In addition, as a special exception, Nokia gives you certain additional
       
    18 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    20 **
       
    21 ** If you have questions regarding the use of this file, please contact
       
    22 ** Nokia at developer.feedback@nokia.com.
       
    23 **
       
    24 ****************************************************************************/
       
    25 
       
    26 #ifndef HB_INPUT_STATE_H
       
    27 #define HB_INPUT_STATE_H
       
    28 
       
    29 #include <hbinputlanguage.h>
       
    30 
       
    31 /*!
       
    32 @alpha
       
    33 @hbcore
       
    34 \class HbInputState
       
    35 \brief Holds all the information for defining an input state.
       
    36 
       
    37 This class describes the state of the input framework.
       
    38 Active input method is notified every time the state changes.
       
    39 If the active input method cannot handle new state, the framework will find 
       
    40 suitable handler for it. The input state is a combination of input mode, text case,
       
    41 keyboard type and language.
       
    42 
       
    43 This class is for input method developers, it should never be needed in application code.
       
    44 
       
    45 \sa HbInputMethod
       
    46 */
       
    47 class HbInputState
       
    48 {
       
    49 public:
       
    50     HbInputState()
       
    51         : iModeType(HbInputModeNone),
       
    52           iTextCase(HbTextCaseNone),
       
    53           iKeyboardType(HbKeyboardNone),
       
    54           iLanguage(HbInputLanguage())
       
    55     {}
       
    56 
       
    57     HbInputState(HbInputModeType aModeType, HbTextCase aTextCase, HbKeyboardType aKeyboardType, const HbInputLanguage &aLanguage = HbInputLanguage())
       
    58         : iModeType(aModeType),
       
    59           iTextCase(aTextCase),
       
    60           iKeyboardType(aKeyboardType),
       
    61           iLanguage(aLanguage)
       
    62     {}
       
    63 
       
    64     void operator=(const HbInputState& aState) {
       
    65         iModeType = aState.iModeType;
       
    66         iTextCase = aState.iTextCase; 
       
    67         iKeyboardType = aState.iKeyboardType;
       
    68         iLanguage = aState.iLanguage;
       
    69     }
       
    70 
       
    71     bool operator==(const HbInputState& aState) {
       
    72         if (iModeType == aState.iModeType
       
    73             && iTextCase == aState.iTextCase
       
    74             && iKeyboardType == aState.iKeyboardType
       
    75             && iLanguage == aState.iLanguage) {
       
    76                 return true;
       
    77         }
       
    78         return false;
       
    79     }
       
    80 
       
    81     /*!
       
    82     This is same as compare operator except for the language value. If either one of the
       
    83     states being compared has undefined language value, it will match to any language.
       
    84     If both language values are defined, then they are compared directly.
       
    85     */
       
    86     bool isMatch(const HbInputState& aState) {
       
    87         if (iModeType == aState.iModeType
       
    88             && iTextCase == aState.iTextCase
       
    89             && iKeyboardType == aState.iKeyboardType
       
    90             && (iLanguage == aState.iLanguage ||
       
    91                 iLanguage.undefined() ||           // Undefined matches to anything.
       
    92         aState.iLanguage.undefined())) {
       
    93                 return true;
       
    94         }
       
    95     return false;
       
    96     }
       
    97 
       
    98     bool operator!=(const HbInputState& aState) {
       
    99         if (iModeType != aState.iModeType
       
   100             || iTextCase != aState.iTextCase
       
   101             || iKeyboardType != aState.iKeyboardType
       
   102             || iLanguage != aState.iLanguage) {
       
   103                 return true;
       
   104         }
       
   105         return false;
       
   106     }
       
   107 
       
   108     /*!
       
   109     Returns input mode.
       
   110     */
       
   111     HbInputModeType inputMode() const { return iModeType; }
       
   112 
       
   113     /*!
       
   114     Sets input mode.
       
   115     */
       
   116     void setInputMode(HbInputModeType newMode) { iModeType = newMode; }
       
   117 
       
   118     /*!
       
   119     Returns text case.
       
   120     */
       
   121     HbTextCase textCase() const { return iTextCase; }
       
   122 
       
   123     /*!
       
   124     Sets text case.
       
   125     */
       
   126     void setTextCase(HbTextCase newCase) { iTextCase = newCase; }
       
   127 
       
   128     /*!
       
   129     Returns keyboard type.
       
   130     */
       
   131     HbKeyboardType keyboard() const { return iKeyboardType; }
       
   132 
       
   133     /*!
       
   134     Sets keyboard type.
       
   135     */
       
   136     void setKeyboard(HbKeyboardType newKeyboard) { iKeyboardType = newKeyboard; } 
       
   137 
       
   138     /*!
       
   139     Returns language.
       
   140     */
       
   141     HbInputLanguage language() const { return HbInputLanguage(iLanguage); }
       
   142 
       
   143     /*!
       
   144     Sets language. 
       
   145     */
       
   146     void setLanguage(const HbInputLanguage &newLanguage) { iLanguage = newLanguage; }
       
   147 
       
   148 private:
       
   149     HbInputModeType iModeType;
       
   150     HbTextCase iTextCase;
       
   151     HbKeyboardType iKeyboardType;
       
   152     HbInputLanguage iLanguage;
       
   153 };
       
   154 
       
   155 #endif // HB_INPUT_STATE_H
       
   156 
       
   157 // End of file