00001
00014
00015
00016
00017 #include "circle.h"
00018
00020
00021
00022
00023
00024
00025
00026 extern const u16 ButtonMenuBmp[];
00027 extern const u16 ButtonLowSoundHPBmp[];
00028 extern const u16 ButtonHighSoundHPBmp[];
00029 extern const u16 ButtonMuteHPBmp[];
00030 extern const u16 ButtonSoundHPBmp[];
00031 extern const u16 ButtonLowSoundLSBmp[];
00032 extern const u16 ButtonHighSoundLSBmp[];
00033 extern const u16 ButtonMuteLSBmp[];
00034 extern const u16 ButtonSoundLSBmp[];
00035
00036
00037 enum MENU_code fLowSound();
00038 enum MENU_code fHighSound();
00039 enum MENU_code fMuteSound();
00040 enum MENU_code fDefaultAction();
00041
00042
00043 s32 ScreenButton = -1;
00044 s32 CurOrientation = V12;
00045 s32 OldOrientation = V12;
00046 s32 RedrawToolbarRequest;
00047 divider_t Max_cnt_tb = 100;
00048
00049 tToolbar* CurrentToolbar = 0;
00050 tToolbarItem* CurrentTbCommand = 0;
00051
00052
00053 tToolbar DefaultToolbar =
00054 {
00055 TB_NB_BUTTONS,
00056 0,
00057 {
00058 { ButtonMenuBmp, fDefaultAction },
00059 { ButtonLowSoundLSBmp, fLowSound },
00060 { ButtonHighSoundLSBmp, fHighSound },
00061 { ButtonMuteLSBmp, fMuteSound },
00062 }
00063 };
00064
00065
00066
00067
00068
00069
00077
00078 NODEBUG void TOOLBAR_Init( void )
00079 {
00080 LCD_FillRect_Circle( 0, PHYS_SCREEN_HEIGHT - BUTTON_HEIGHT, PHYS_SCREEN_WIDTH, BUTTON_HEIGHT, RGB_WHITE );
00081 TOOLBAR_SetDefaultToolbar();
00082 }
00083
00084
00085
00086
00087
00088
00096
00097 void TOOLBAR_Handler( void )
00098 {
00099 static divider_t divider_coord = 0;
00100 s32 OldButton = ScreenButton;
00101 s32 X, Y;
00102 vs32 i;
00103
00104
00105 if ( ( divider_coord++ % Max_cnt_tb ) != 0 )
00106 return;
00107
00108
00109 if ( TOUCHSCR_GetMode() == TS_CALIBRATION )
00110 return;
00111
00112
00113 if ( TOUCHSCR_IsPressed() )
00114 {
00115
00116 X = TOUCHSCR_Info.xAbsPos;
00117 Y = TOUCHSCR_Info.yAbsPos;
00118
00119
00120 if ( Y > APP_SCREEN_HEIGHT )
00121 {
00122
00123 ScreenButton = X / BUTTON_WIDTH;
00124 if ( ScreenButton > ( CurrentToolbar->NbItems - 1 ) )
00125 {
00126 ScreenButton = CurrentToolbar->NbItems - 1;
00127 }
00128 if ( ScreenButton < 0 )
00129 {
00130 ScreenButton = 0;
00131 }
00132 }
00133 else
00134
00135 ScreenButton = -1;
00136 }
00137 else
00138 {
00139
00140 if ( RedrawToolbarRequest )
00141 {
00142 if ( ( RedrawToolbarRequest >> 4 ) )
00143 {
00144
00145 CurrentToolbar = &DefaultToolbar;
00146 if ( AUDIO_SpeakerOn )
00147 {
00148 TOOLBAR_ChangeButton( 0, ButtonMenuBmp, fDefaultAction );
00149 TOOLBAR_ChangeButton( 1, ButtonLowSoundLSBmp, fLowSound );
00150 TOOLBAR_ChangeButton( 2, ButtonHighSoundLSBmp, fHighSound );
00151 TOOLBAR_ChangeButton( 3, AUDIO_IsMute() ? ButtonMuteLSBmp : ButtonSoundLSBmp, fMuteSound );
00152 }
00153 else
00154 {
00155 TOOLBAR_ChangeButton( 0, ButtonMenuBmp, fDefaultAction );
00156 TOOLBAR_ChangeButton( 1, ButtonLowSoundHPBmp, fLowSound );
00157 TOOLBAR_ChangeButton( 2, ButtonHighSoundHPBmp, fHighSound );
00158 TOOLBAR_ChangeButton( 3, AUDIO_IsMute() ? ButtonMuteHPBmp : ButtonSoundHPBmp, fMuteSound );
00159 }
00160 }
00161
00162
00163 if ( RedrawToolbarRequest & 0x0F )
00164 {
00165
00166 for ( i = 0 ; i < CurrentToolbar->NbItems ; i++ )
00167 {
00168 if ( ( RedrawToolbarRequest >> i ) & 1 )
00169 TOOLBAR_UnSelectButton( i );
00170 }
00171 }
00172
00173
00174 RedrawToolbarRequest = 0;
00175 }
00176
00177
00178 OldOrientation = CurOrientation;
00179
00180
00181 ScreenButton = -1;
00182
00183 }
00184
00185
00186 if ( OldButton != ScreenButton )
00187 {
00188 if ( OldButton != -1 )
00189 TOOLBAR_UnSelectButton( OldButton );
00190
00191 if ( ScreenButton != -1 )
00192 TOOLBAR_SelectButton( ScreenButton );
00193 }
00194
00195 }
00196
00197
00198
00199
00200
00201
00202
00209
00210 void TOOLBAR_UnSelectButton( u16 button )
00211 {
00212 TOOLBAR_Button( button, DEFAULT_BUTTON_BGND, DEFAULT_BUTTON_BGND, FALSE );
00213 }
00214
00215
00216
00217
00218
00219
00227
00228 void TOOLBAR_SelectButton( u16 button )
00229 {
00230 s32 index;
00231
00232
00233 TOOLBAR_Button( button, DEFAULT_BUTTON_BGND, ACTIVE_BUTTON_BGND, TRUE ) ;
00234
00235
00236 if ( BUZZER_GetMode() == BUZZER_OFF )
00237 {
00238 BUZZER_SetFrequency( 440 );
00239 BUZZER_SetMode( BUZZER_SHORTBEEP );
00240 }
00241
00242
00243 index = ( button + CurrentToolbar->FirstDispItem ) % CurrentToolbar->NbItems;
00244 if ( CurrentToolbar->Items[index].Fct_Manage )
00245 {
00246 #if POWER_MNGT
00247 POWER_Reset_Time();
00248 #endif
00249 CurrentToolbar->Items[index].Fct_Manage();
00250 #if POWER_MNGT
00251 POWER_Set_Time();
00252 #endif
00253 }
00254 }
00255
00256
00257
00258
00259
00260
00270
00271 void TOOLBAR_Button( u16 button, u16 bgnd_color, u16 bgnd_color_sel, bool sel )
00272 {
00273 s32 index, deltaWidth, deltaHeight, Icon_Width, Icon_Height;
00274 coord_t Save_Screen_Width, Save_Screen_Height, Save_LCD_Offset;
00275
00276
00277 index = ( button + CurrentToolbar->FirstDispItem ) % CurrentToolbar->NbItems;
00278
00279
00280 if ( ( CurrentToolbar->Items[index].icon[0] == 0x424D ) && ( CurrentToolbar->Items[index].icon[3] == 0 ) )
00281 {
00282 Icon_Width = ( CurrentToolbar->Items[index].icon[9] ) >> 8;
00283 Icon_Height = ( CurrentToolbar->Items[index].icon[11] ) >> 8;
00284 }
00285 else
00286 {
00287 Icon_Width = ICON_WIDTH;
00288 Icon_Height = ICON_HEIGHT;
00289 }
00290
00291
00292 deltaWidth = ( BUTTON_WIDTH - Icon_Width ) / 2;
00293 deltaHeight = ( BUTTON_HEIGHT - Icon_Height ) / 2;
00294
00295
00296 Save_Screen_Width = LCD_GetScreenWidth();
00297 Save_Screen_Height = LCD_GetScreenHeight();
00298 Save_LCD_Offset = LCD_Offset;
00299
00300
00301 Screen_Width = APP_SCREEN_WIDTH;
00302 Screen_Height = APP_SCREEN_HEIGHT;
00303 LCD_Offset = 0;
00304
00305 switch ( LCD_GetScreenOrientation() )
00306 {
00307 case V12:
00308 LCD_FillRect_Circle( BUTTON_WIDTH * button, APP_SCREEN_HEIGHT, BUTTON_WIDTH, BUTTON_HEIGHT, RGB_WHITE );
00309
00310 if ( sel )
00311 DRAW_SetImageSel( CurrentToolbar->Items[index].icon, ( BUTTON_WIDTH * button ) + deltaWidth, APP_SCREEN_HEIGHT + deltaHeight, Icon_Height, Icon_Width,
00312 bgnd_color, bgnd_color_sel );
00313 else
00314 DRAW_SetImage( CurrentToolbar->Items[index].icon, ( BUTTON_WIDTH * button ) + deltaWidth, APP_SCREEN_HEIGHT + deltaHeight, Icon_Height, Icon_Width );
00315
00316 DRAW_Line_Circle( BUTTON_WIDTH * button, APP_SCREEN_HEIGHT, BUTTON_WIDTH * ( button + 1 ) - 1, APP_SCREEN_HEIGHT, RGB_BUTTON_SEPARATOR );
00317
00318 if ( index != ( CurrentToolbar->NbItems - 1 ) )
00319 DRAW_Line_Circle( BUTTON_WIDTH * ( button + 1 ) - 1, APP_SCREEN_HEIGHT, BUTTON_WIDTH * ( button + 1 ) - 1, APP_SCREEN_HEIGHT + BUTTON_HEIGHT - 1, RGB_BUTTON_SEPARATOR );
00320 break;
00321
00322 case V3:
00323 LCD_FillRect_Circle( APP_SCREEN_WIDTH, BUTTON_WIDTH * ( CurrentToolbar->NbItems - button - 1 ), BUTTON_HEIGHT, BUTTON_WIDTH, RGB_WHITE );
00324
00325 if ( sel )
00326 DRAW_SetImageSel( CurrentToolbar->Items[index].icon, APP_SCREEN_WIDTH + deltaHeight, BUTTON_WIDTH * ( CurrentToolbar->NbItems - button - 1 ) + deltaWidth, Icon_Width, Icon_Height,
00327 bgnd_color, bgnd_color_sel );
00328 else
00329 DRAW_SetImage( CurrentToolbar->Items[index].icon, APP_SCREEN_WIDTH + deltaHeight, BUTTON_WIDTH * ( CurrentToolbar->NbItems - button - 1 ) + deltaWidth, Icon_Width, Icon_Height );
00330
00331 DRAW_Line_Circle( APP_SCREEN_WIDTH, BUTTON_WIDTH * ( CurrentToolbar->NbItems - button - 1 ), APP_SCREEN_WIDTH, BUTTON_WIDTH * ( CurrentToolbar->NbItems - button ), RGB_BUTTON_SEPARATOR );
00332
00333 if ( index != ( CurrentToolbar->NbItems - 1 ) )
00334 DRAW_Line_Circle( APP_SCREEN_WIDTH + BUTTON_HEIGHT, BUTTON_WIDTH * ( CurrentToolbar->NbItems - button - 1 ), APP_SCREEN_WIDTH, BUTTON_WIDTH * ( CurrentToolbar->NbItems - button - 1 ), RGB_BUTTON_SEPARATOR );
00335 break;
00336
00337 case V6:
00338 LCD_FillRect_Circle( BUTTON_WIDTH * ( CurrentToolbar->NbItems - button - 1 ), -BUTTON_HEIGHT, BUTTON_WIDTH, BUTTON_HEIGHT, RGB_WHITE );
00339
00340 if ( sel )
00341 DRAW_SetImageSel( CurrentToolbar->Items[index].icon, ( BUTTON_WIDTH * ( CurrentToolbar->NbItems - button - 1 ) ) + deltaWidth, -BUTTON_HEIGHT + deltaHeight, Icon_Height, Icon_Width,
00342 bgnd_color, bgnd_color_sel );
00343 else
00344 DRAW_SetImage( CurrentToolbar->Items[index].icon, ( BUTTON_WIDTH * ( CurrentToolbar->NbItems - button - 1 ) ) + deltaWidth, -BUTTON_HEIGHT + deltaHeight, Icon_Height, Icon_Width );
00345
00346 DRAW_Line_Circle( BUTTON_WIDTH * ( CurrentToolbar->NbItems - button - 1 ), -1, BUTTON_WIDTH * ( CurrentToolbar->NbItems - button ), -1, RGB_BUTTON_SEPARATOR );
00347
00348 if ( index != ( CurrentToolbar->NbItems - 1 ) )
00349 DRAW_Line_Circle( BUTTON_WIDTH * ( CurrentToolbar->NbItems - button - 1 ), -BUTTON_HEIGHT, BUTTON_WIDTH * ( CurrentToolbar->NbItems - button - 1 ), -1, RGB_BUTTON_SEPARATOR );
00350 break;
00351
00352 case V9:
00353 LCD_FillRect_Circle( -BUTTON_HEIGHT, BUTTON_WIDTH * button, BUTTON_HEIGHT, BUTTON_WIDTH, RGB_WHITE );
00354
00355 if ( sel )
00356 DRAW_SetImageSel( CurrentToolbar->Items[index].icon, -BUTTON_HEIGHT + deltaHeight, ( BUTTON_WIDTH * button ) + deltaWidth, Icon_Height, Icon_Width,
00357 bgnd_color, bgnd_color_sel );
00358 else
00359 DRAW_SetImage( CurrentToolbar->Items[index].icon, -BUTTON_HEIGHT + deltaHeight, ( BUTTON_WIDTH * button ) + deltaWidth, Icon_Height, Icon_Width );
00360
00361 DRAW_Line_Circle( -1, BUTTON_WIDTH * button, -1, BUTTON_WIDTH * ( button + 1 ) - 1, RGB_BUTTON_SEPARATOR );
00362
00363 if ( index != ( CurrentToolbar->NbItems - 1 ) )
00364 DRAW_Line_Circle( -1, BUTTON_WIDTH * ( button + 1 ) - 1, -BUTTON_HEIGHT, BUTTON_WIDTH * ( button + 1 ) - 1, RGB_BUTTON_SEPARATOR );
00365 break;
00366 }
00367
00368
00369 Screen_Width = Save_Screen_Width;
00370 Screen_Height = Save_Screen_Height;
00371 LCD_Offset = Save_LCD_Offset;
00372 }
00373
00374
00375
00376
00377
00378
00379 enum MENU_code fLowSound( void )
00380 {
00381 AUDIO_Dec_Volume( 2 );
00382 return MENU_CONTINUE;
00383 }
00384
00385 enum MENU_code fHighSound( void )
00386 {
00387 AUDIO_Inc_Volume( 2 );
00388 return MENU_CONTINUE;
00389 }
00390
00391 enum MENU_code fMuteSound( void )
00392 {
00393 AUDIO_MUTE_OnOff( AUDIO_IsMute() ? 0 : 1 );
00394
00395 if ( AUDIO_SpeakerOn )
00396 TOOLBAR_ChangeButton( 3, AUDIO_IsMute() ? ButtonMuteLSBmp : ButtonSoundLSBmp, fMuteSound );
00397 else
00398 TOOLBAR_ChangeButton( 3, AUDIO_IsMute() ? ButtonMuteHPBmp : ButtonSoundHPBmp, fMuteSound );
00399
00400 return MENU_CONTINUE;
00401 }
00402
00403 enum MENU_code fDefaultAction( void )
00404 {
00405 index_t CurrentApplicationIndex = -1;
00406
00407 if ( fInitDone == FALSE )
00408 return MENU_CONTINUE;
00409
00410
00411 CurrentApplicationIndex = UTIL_ReadBackupRegister( BKP_SYS1 );
00412
00413
00414 if ( APP_LaunchAppli( CurrentApplicationIndex ) == MENU_LEAVE )
00415 {
00416 return fConfig();
00417 }
00418 else
00419 {
00420 return MENU_CONTINUE;
00421 }
00422 }
00423
00424
00425
00426
00427
00428
00440
00441 void TOOLBAR_RedrawToolbar( s32 Request )
00442 {
00443 RedrawToolbarRequest |= Request;
00444 }
00445
00447
00448
00449
00450
00451
00452
00459
00460 void TOOLBAR_Set( const tToolbar* NewToolbar )
00461 {
00462 CurrentToolbar = ( tToolbar* ) NewToolbar;
00463 TOOLBAR_RedrawToolbar( TOOLBAR_REDRAW );
00464 }
00465
00466
00467
00468
00469
00470
00476
00477 void TOOLBAR_SetDefaultToolbar( void )
00478 {
00479 TOOLBAR_RedrawToolbar( TOOLBAR_DEFAULT );
00480 }
00481
00482
00483
00484
00485
00486
00495
00496 void TOOLBAR_ChangeButton( s32 button, const u16* newicon, enum MENU_code( *newfct )( void ) )
00497 {
00498 CurrentToolbar->Items[button].icon = newicon;
00499 CurrentToolbar->Items[button].Fct_Manage = newfct;
00500 TOOLBAR_RedrawToolbar( 1 << button );
00501 }
00502
00503
00504