equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
274 |
274 |
275 // --------------------------------------------------------------------------- |
275 // --------------------------------------------------------------------------- |
276 // Retrieves next focusable button. |
276 // Retrieves next focusable button. |
277 // --------------------------------------------------------------------------- |
277 // --------------------------------------------------------------------------- |
278 // |
278 // |
279 CFsControlButton* CFsControlBarModel::NextButton( TInt aButtonId ) |
279 CFsControlButton* CFsControlBarModel::NextButton( |
280 { |
280 TInt aButtonId, TBool aLandscape ) |
281 FUNC_LOG; |
281 { |
282 TInt index( -1 ); |
282 FUNC_LOG; |
|
283 TInt index( KErrNotFound ); |
283 CFsControlButton* currentBtn( ButtonById( aButtonId ) ); |
284 CFsControlButton* currentBtn( ButtonById( aButtonId ) ); |
284 |
285 |
285 // Find current button's id. |
286 // Find current button's id. |
286 TInt buttonId( 0 ); |
287 TInt buttonId( 0 ); |
287 while ( iButtons.Count() > buttonId ) |
288 while ( iButtons.Count() > buttonId ) |
292 } |
293 } |
293 buttonId++; |
294 buttonId++; |
294 } |
295 } |
295 |
296 |
296 // Find the next button on right. |
297 // Find the next button on right. |
297 TInt curPos( currentBtn->Visualiser()->Pos().Target().iX ); |
298 TAlfRealPoint curPosTarget( currentBtn->Visualiser()->Pos().Target() ); |
|
299 TInt curPos( curPosTarget.iX ); |
|
300 if( aLandscape ) |
|
301 { |
|
302 curPos = curPosTarget.iY; |
|
303 } |
|
304 |
298 TBool candidate( EFalse ); |
305 TBool candidate( EFalse ); |
299 TInt next( 0 ); |
306 TInt next( 0 ); |
300 for ( TInt i( 0 ); iButtons.Count() > i; i++ ) |
307 for ( TInt i( 0 ); iButtons.Count() > i; i++ ) |
301 { |
308 { |
302 if ( i == buttonId |
309 if ( i == buttonId |
303 || !iButtons[i]->IsVisible() |
310 || !iButtons[i]->IsVisible() |
304 || iButtons[i]->IsDimmed() ) |
311 || iButtons[i]->IsDimmed() ) |
305 { |
312 { |
306 continue; |
313 continue; |
307 } |
314 } |
308 TInt btnPos( iButtons[i]->Visualiser()->Pos().Target().iX ); |
315 TAlfRealPoint btnPosTarget( iButtons[i]->Visualiser()->Pos().Target() ); |
|
316 TInt btnPos( btnPosTarget.iX ); |
|
317 if( aLandscape ) |
|
318 { |
|
319 btnPos = btnPosTarget.iY; |
|
320 } |
309 if ( btnPos >= curPos ) |
321 if ( btnPos >= curPos ) |
310 { |
322 { |
311 if ( btnPos == curPos ) |
323 if ( btnPos == curPos ) |
312 { |
324 { |
313 if ( i < buttonId ) |
325 if ( i < buttonId ) |
340 |
352 |
341 // --------------------------------------------------------------------------- |
353 // --------------------------------------------------------------------------- |
342 // Retrieves previous focusable button. |
354 // Retrieves previous focusable button. |
343 // --------------------------------------------------------------------------- |
355 // --------------------------------------------------------------------------- |
344 // |
356 // |
345 CFsControlButton* CFsControlBarModel::PrevButton( TInt aButtonId ) |
357 CFsControlButton* CFsControlBarModel::PrevButton( |
346 { |
358 TInt aButtonId, TBool aLandscape ) |
347 FUNC_LOG; |
359 { |
348 TInt index( -1 ); |
360 FUNC_LOG; |
|
361 TInt index( KErrNotFound ); |
349 CFsControlButton* currentBtn( ButtonById( aButtonId ) ); |
362 CFsControlButton* currentBtn( ButtonById( aButtonId ) ); |
350 |
363 |
351 // Find current button's id. |
364 // Find current button's id. |
352 TInt buttonId( 0 ); |
365 TInt buttonId( 0 ); |
353 while ( iButtons.Count() > buttonId ) |
366 while ( iButtons.Count() > buttonId ) |
357 break; |
370 break; |
358 } |
371 } |
359 buttonId++; |
372 buttonId++; |
360 } |
373 } |
361 |
374 |
362 // Find the next button on left. |
375 // Find the next button on left or up. |
363 TInt curPos( currentBtn->Visualiser()->Pos().Target().iX ); |
376 TAlfRealPoint curPosTaget( currentBtn->Visualiser()->Pos().Target() ); |
|
377 |
|
378 TInt curPos( curPosTaget.iX ); |
|
379 if( aLandscape ) |
|
380 { |
|
381 curPos = curPosTaget.iY; |
|
382 } |
364 TBool candidate( EFalse ); |
383 TBool candidate( EFalse ); |
365 TInt next( 0 ); |
384 TInt next( 0 ); |
366 for ( TInt i( iButtons.Count() - 1 ); 0 <= i; i-- ) |
385 for ( TInt i( iButtons.Count() - 1 ); 0 <= i; i-- ) |
367 { |
386 { |
368 if ( i == buttonId |
387 if ( ( i == buttonId ) || |
369 || !iButtons[i]->IsVisible() |
388 ( !iButtons[i]->IsVisible() ) || |
370 || iButtons[i]->IsDimmed() ) |
389 ( iButtons[i]->IsDimmed() ) ) |
371 { |
390 { |
372 continue; |
391 continue; |
373 } |
392 } |
374 TInt btnPos( iButtons[i]->Visualiser()->Pos().Target().iX ); |
393 TAlfRealPoint btnPosTarget( iButtons[i]->Visualiser()->Pos().Target() ); |
|
394 TInt btnPos( btnPosTarget.iX ); |
|
395 if( aLandscape ) |
|
396 { |
|
397 btnPos = btnPosTarget.iY; |
|
398 } |
375 if ( btnPos <= curPos ) |
399 if ( btnPos <= curPos ) |
376 { |
400 { |
377 if ( btnPos == curPos ) |
401 if ( btnPos == curPos ) |
378 { |
402 { |
379 if ( i > buttonId ) |
403 if ( i > buttonId ) |