src/hbinput/inputwidgets/hbinputbutton.cpp
changeset 7 923ff622b8b9
parent 6 c3690ec91ef8
child 21 4633027730f5
child 34 ed14f46c0e55
equal deleted inserted replaced
6:c3690ec91ef8 7:923ff622b8b9
    73 
    73 
    74     for (int i = 0; i < HbInputButton::ButtonIconIndexCount; ++i) {
    74     for (int i = 0; i < HbInputButton::ButtonIconIndexCount; ++i) {
    75         mIcons.append(HbIcon());
    75         mIcons.append(HbIcon());
    76     }
    76     }
    77 
    77 
    78     if (keyCode != HbInputButton::ButtonKeyCodeCharacter) {
    78     if (keyCode != HbInputButton::ButtonKeyCodeCharacter &&
       
    79         keyCode != HbInputButton::ButtonKeyCodeSpace) {
    79         mType = HbInputButton::ButtonTypeFunction;
    80         mType = HbInputButton::ButtonTypeFunction;
    80     }
    81     }
    81 
    82 
    82     setDefaultGraphics(keyCode);
    83     setDefaultGraphics(keyCode);
    83 
    84 
   123     }
   124     }
   124 }
   125 }
   125 
   126 
   126 void HbInputButtonPrivate::setDefaultGraphics(int keyCode)
   127 void HbInputButtonPrivate::setDefaultGraphics(int keyCode)
   127 {
   128 {
   128     if (keyCode == HbInputButton::ButtonKeyCodeDelete) {
   129     switch(keyCode) {
   129         mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconDelete));
   130         case HbInputButton::ButtonKeyCodeDelete:
   130     } else if (keyCode == HbInputButton::ButtonKeyCodeShift) {
   131             mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconDelete));
   131         mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconShift));
   132             break;
   132     } else if (keyCode == HbInputButton::ButtonKeyCodeSymbol) {
   133         case HbInputButton::ButtonKeyCodeShift:
   133         mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconSymbol));
   134             mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconShift));
   134     } else if (keyCode == HbInputButton::ButtonKeyCodeEnter) {
   135             break;
   135         mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconEnter));
   136         case HbInputButton::ButtonKeyCodeSymbol:
   136     } else if (keyCode == HbInputButton::ButtonKeyCodeSpace) {
   137             mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconSymbol));
   137         mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconSpace));
   138             break;
   138     } else if (keyCode == HbInputButton::ButtonKeyCodeAlphabet) {
   139         case HbInputButton::ButtonKeyCodeEnter:
   139         mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconAlphabet));
   140             mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconEnter));
   140     } else if (keyCode == HbInputButton::ButtonKeyCodePageChange) {
   141             break;
   141         mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconPageChange));
   142         case HbInputButton::ButtonKeyCodeSpace:
   142     } else if (keyCode == HbInputButton::ButtonKeyCodeSmiley) {
   143             mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconSpace));
   143         mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconSmiley));
   144             break;
       
   145         case HbInputButton::ButtonKeyCodeAlphabet:
       
   146             mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconSymbol));
       
   147             break;
       
   148         case HbInputButton::ButtonKeyCodeSmiley:
       
   149             mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconSmiley));
       
   150             break;
       
   151         default:
       
   152             break;
   144     }
   153     }
   145 }
   154 }
   146 
   155 
   147 /// @endcond
   156 /// @endcond
   148 
   157 
   174 {
   183 {
   175     delete d_ptr;
   184     delete d_ptr;
   176 }
   185 }
   177 
   186 
   178 /*!
   187 /*!
   179 Updates buttons type.
   188 Updates button's type.
   180 
   189 
   181 \sa type
   190 \sa type
   182 */
   191 */
   183 void HbInputButton::setType(HbInputButtonType type)
   192 void HbInputButton::setType(HbInputButtonType type)
   184 {
   193 {
   186 
   195 
   187     d->mType = type;
   196     d->mType = type;
   188 }
   197 }
   189 
   198 
   190 /*!
   199 /*!
   191 Returns buttons type.
   200 Returns button's type.
   192 
   201 
   193 \sa setType
   202 \sa setType
   194 */
   203 */
   195 HbInputButton::HbInputButtonType HbInputButton::type() const
   204 HbInputButton::HbInputButtonType HbInputButton::type() const
   196 {
   205 {
   198 
   207 
   199     return d->mType;
   208     return d->mType;
   200 }
   209 }
   201 
   210 
   202 /*!
   211 /*!
   203 Updates buttons state.
   212 Updates button's state.
   204 
   213 
   205 \sa state
   214 \sa state
   206 */
   215 */
   207 void HbInputButton::setState(HbInputButtonState state)
   216 void HbInputButton::setState(HbInputButtonState state)
   208 {
   217 {
   210 
   219 
   211     d->mState = state;
   220     d->mState = state;
   212 }
   221 }
   213 
   222 
   214 /*!
   223 /*!
   215 Returns buttons state.
   224 Returns button's state.
   216 
   225 
   217 \sa setState
   226 \sa setState
   218 */
   227 */
   219 HbInputButton::HbInputButtonState HbInputButton::state() const
   228 HbInputButton::HbInputButtonState HbInputButton::state() const
   220 {
   229 {
   222 
   231 
   223     return d->mState;
   232     return d->mState;
   224 }
   233 }
   225 
   234 
   226 /*!
   235 /*!
   227 Updates buttons position.
   236 Updates button's position.
   228 
   237 
   229 position is button's position in grid cell units.
   238 position is button's position in grid cell units.
   230 
   239 
   231 \sa position
   240 \sa position
   232 */
   241 */
   236 
   245 
   237     d->mPosition = position;
   246     d->mPosition = position;
   238 }
   247 }
   239 
   248 
   240 /*!
   249 /*!
   241 Returns buttons position.
   250 Returns button's position.
   242 
   251 
   243 \sa setPosition
   252 \sa setPosition
   244 */
   253 */
   245 QPoint HbInputButton::position() const
   254 QPoint HbInputButton::position() const
   246 {
   255 {
   248 
   257 
   249     return d->mPosition;
   258     return d->mPosition;
   250 }
   259 }
   251 
   260 
   252 /*!
   261 /*!
   253 Updates buttons size.
   262 Updates button's size.
   254 
   263 
   255 size is button's size in grid cell units.
   264 size is button's size in grid cell units.
   256 
   265 
   257 \sa size
   266 \sa size
   258 */
   267 */
   262 
   271 
   263     d->mSize = size;
   272     d->mSize = size;
   264 }
   273 }
   265 
   274 
   266 /*!
   275 /*!
   267 Returns buttons size.
   276 Returns button's size.
   268 
   277 
   269 \sa setSize
   278 \sa setSize
   270 */
   279 */
   271 QSize HbInputButton::size() const
   280 QSize HbInputButton::size() const
   272 {
   281 {
   274 
   283 
   275     return d->mSize;
   284     return d->mSize;
   276 }
   285 }
   277 
   286 
   278 /*!
   287 /*!
   279 Updates buttons key code.
   288 Updates button's key code.
   280 
   289 
   281 \sa keyCode
   290 \sa keyCode
   282 */
   291 */
   283 void HbInputButton::setKeyCode(int keyCode)
   292 void HbInputButton::setKeyCode(int keyCode)
   284 {
   293 {
   286 
   295 
   287     d->mKeyCode = keyCode;
   296     d->mKeyCode = keyCode;
   288 }
   297 }
   289 
   298 
   290 /*!
   299 /*!
   291 Returns buttons key code.
   300 Returns button's key code.
   292 
   301 
   293 \sa setKeyCode
   302 \sa setKeyCode
   294 */
   303 */
   295 int HbInputButton::keyCode() const
   304 int HbInputButton::keyCode() const
   296 {
   305 {
   298 
   307 
   299     return d->mKeyCode;
   308     return d->mKeyCode;
   300 }
   309 }
   301 
   310 
   302 /*!
   311 /*!
   303 Updates buttons auto repeat status.
   312 Updates button's auto repeat status.
   304 
   313 
   305 \sa autoRepeat
   314 \sa autoRepeat
   306 */
   315 */
   307 void HbInputButton::setAutoRepeat(bool autoRepeat)
   316 void HbInputButton::setAutoRepeat(bool autoRepeat)
   308 {
   317 {
   310 
   319 
   311     d->mAutoRepeat = autoRepeat;
   320     d->mAutoRepeat = autoRepeat;
   312 }
   321 }
   313 
   322 
   314 /*!
   323 /*!
   315 Returns buttons auto repeat status.
   324 Returns button's auto repeat status.
   316 
   325 
   317 \sa setAutoRepeat
   326 \sa setAutoRepeat
   318 */
   327 */
   319 bool HbInputButton::autoRepeat() const
   328 bool HbInputButton::autoRepeat() const
   320 {
   329 {
   338         d->mTexts.replace(index, text);
   347         d->mTexts.replace(index, text);
   339     }
   348     }
   340 }
   349 }
   341 
   350 
   342 /*!
   351 /*!
   343 Updates all button texts.
   352 Updates all button's texts.
   344 Button can have three different texts. Text position and size
   353 Button can have three different texts. Text position and size
   345 will depend of other buttons texts and icons. If list contains
   354 will depend on other buttons texts and icons. If list contains
   346 more strings, then the rest will be ignored. Icon with same index
   355 more strings, then the rest will be ignored. Icon with same index
   347 than text will override the text.
   356 as text will override the text.
   348 
   357 
   349 \sa text
   358 \sa text
   350 \sa texts
   359 \sa texts
   351 */
   360 */
   352 void HbInputButton::setTexts(const QList<QString> &texts)
   361 void HbInputButton::setTexts(const QList<QString> &texts)
   378 
   387 
   379     return d->mTexts.at(index);
   388     return d->mTexts.at(index);
   380 }
   389 }
   381 
   390 
   382 /*!
   391 /*!
   383 Returns all button texts.
   392 Returns all button's texts.
   384 
   393 
   385 \sa setText
   394 \sa setText
   386 \sa setTexts
   395 \sa setTexts
   387 */
   396 */
   388 QList<QString> HbInputButton::texts() const
   397 QList<QString> HbInputButton::texts() const
   433 }
   442 }
   434 
   443 
   435 /*!
   444 /*!
   436 Updates all button icons.
   445 Updates all button icons.
   437 Button can have three different icons. Icon position
   446 Button can have three different icons. Icon position
   438 will depend of other buttons icons and texts. If list contains
   447 will depend on other buttons icons and texts. If list contains
   439 more icons, then the rest will be ignored. Icon with same index
   448 more icons, then the rest will be ignored. Icon with same index
   440 than text will override the text.
   449 as text will override the text.
   441 
   450 
   442 \sa icon
   451 \sa icon
   443 \sa icons
   452 \sa icons
   444 */
   453 */
   445 void HbInputButton::setIcons(const QList<HbIcon> &icons)
   454 void HbInputButton::setIcons(const QList<HbIcon> &icons)
   470     }
   479     }
   471     return d->mIcons.at(index);
   480     return d->mIcons.at(index);
   472 }
   481 }
   473 
   482 
   474 /*!
   483 /*!
   475 Returns all button icon.
   484 Returns all button's icons.
   476 
   485 
   477 \sa setIcon
   486 \sa setIcon
   478 \sa setIcons
   487 \sa setIcons
   479 */
   488 */
   480 QList<HbIcon> HbInputButton::icons() const
   489 QList<HbIcon> HbInputButton::icons() const
   495 
   504 
   496     d->mBoundingRect = rect;
   505     d->mBoundingRect = rect;
   497 }
   506 }
   498 
   507 
   499 /*!
   508 /*!
   500 Returns buttons bounding rectangle.
   509 Returns button's bounding rectangle.
   501 
   510 
   502 \sa setBoundingRect
   511 \sa setBoundingRect
   503 */
   512 */
   504 QRectF HbInputButton::boundingRect() const
   513 QRectF HbInputButton::boundingRect() const
   505 {
   514 {