/** Auxiliary Function for T-CoGridStep-RunTestStepL.\n Handles the following Key Events\n 1. Ctrl+ e - Exits the application\n 2. Ctrl+ t - Toggles the Title Lines\n 3. Ctrl+ r - Resets the grid to its default layout and sets the cursor position to the cell at the top of the window\n 4. Ctrl+ m - Sets the zoom factor \n 5. Ctrl+ p - Paginates the Grid \n 6. Ctrl+ i - Inserts columns \n 7. Ctrl+ d - Deletes columns \n 8. Ctrl+ c - Changes the grid colour settings\n 9. Shift+m - Sets the zoom factor\n @return TKeyResponse indicating whether the key event has been handled or not.\n */ TKeyResponse CTestCoeGridAppUi::HandleKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) { if (aType==EEventKey) { if ((aKeyEvent.iModifiers&EAllStdModifiers)==EModifierCtrl) { switch (aKeyEvent.iCode) { case CTRL('e'): SaveL(); iCoeEnv->Flush(); CBaActiveScheduler::Exit(); break; case CTRL('t'): iGridWin->GridLay()->ToggleTitleLinesL(); break; case CTRL('r'): iGridWin->GridLay()->SetGridToDefault(); iUndoColors=EFalse; iUndoColors =~iUndoColors; ChangeColors(iUndoColors); iGridWin->DrawNow(); iGridWin->SetCursorPosL(iGridWin->GridLay()->VisibleRange().iFrom); break; case CTRL('m'): { TInt zoomFactor=iZoomFactor->ZoomFactor(); zoomFactor=(zoomFactor<(TZoomFactor::EZoomOneToOne*4)) ? zoomFactor*2 : TZoomFactor::EZoomOneToOne/4; SetZoomFactorL(zoomFactor); break; } case CTRL('p'): iGridWin->GridLay()->SetPageSizeInTwipsL (TSize(EPageWidthInTwips,EPageHeightInTwips)); iGridWin->GridLay()->PaginateL(); iGridWin->DrawNow(); break; case CTRL('c'): { iUndoColors = ~iUndoColors; ChangeColors(iUndoColors); iGridWin->DrawNow(); } break; case CTRL('i'): case CTRL('d'): { TInt noOfCols=(aKeyEvent.iCode==CTRL('i')) ? 1 : -1; iGridLay->InsertDeleteColumns(iGridLay->VisibleRange().iFrom.iCol, noOfCols,CGridLay::EAdjustGridRange); iGridWin->DrawNow(); } break; case CTRL('z'): { iGridTable->iZeroRows=!iGridTable->iZeroRows; iGridImg->ResetReferencePoints(); iGridLay->ResetVisibleToCell(); iGridWin->DrawNow(); } break; default: break; } } else if ((aKeyEvent.iModifiers&EAllStdModifiers)==EModifierShift) { switch (User::LowerCase(aKeyEvent.iCode)) { case 'm': { TInt zoomFactor=iZoomFactor->ZoomFactor(); zoomFactor=(zoomFactor>(TZoomFactor::EZoomOneToOne/4)) ? zoomFactor/2 : TZoomFactor::EZoomOneToOne*4; SetZoomFactorL(zoomFactor); break; } default: break; } } } return EKeyWasConsumed; }
LDV_STATUS cdecl Run(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out) { LDV_PALETTE *vdi_palette = &in->Palette ; VDI_ELEMENTPAL *vdi_epal ; double rgamma, ggamma, bgamma ; short vdi_index ; short cancel = 0 ; if ( (params->Param[0].s / 100.0) != gamma_rgb ) { gamma_rgb = params->Param[0].s / 100.0 ; params->Param[1].s = params->Param[0].s ; params->Param[2].s = params->Param[0].s ; params->Param[3].s = params->Param[0].s ; } rgamma = params->Param[1].s / 100.0 ; ggamma = params->Param[2].s / 100.0 ; bgamma = params->Param[3].s / 100.0 ; if ( in->Raster.fd_nplanes <= 8 ) { if ( vdi_palette == NULL ) return( ELDV_GENERALFAILURE ) ; vdi_epal = vdi_palette->Pal ; if ( vdi_epal == NULL ) return( ELDV_GENERALFAILURE ) ; for ( vdi_index = 0; vdi_index < vdi_palette->NbColors; vdi_index++, vdi_epal++ ) { vdi_epal->Red = (short) ( 0.5 + GammaFunc( vdi_epal->Red, 1000.0, rgamma ) ) ; if ( ggamma == rgamma ) vdi_epal->Green = vdi_epal->Red ; else vdi_epal->Green = (short) ( 0.5 + GammaFunc( vdi_epal->Green, 1000.0, ggamma ) ) ; if ( bgamma == rgamma ) vdi_epal->Blue = vdi_epal->Red ; else vdi_epal->Blue = (short) ( 0.5 + GammaFunc( vdi_epal->Blue, 1000.0, bgamma ) ) ; } } else { REMAP_COLORS rc ; MFDB *img = &in->Raster ; long *pt_line32, nb_pts_in_line ; short *pt_line16, y, pc, is_15bits, cancel=0 ; unsigned short nb_bits_red=8, nb_bits_green=8, nb_bits_blue=8 ; /* Sur 32 bits par defaut */ CHECK_VAPI(Vapi) ; rc.red = RedRemap ; rc.green = GreenRemap ; rc.blue = BlueRemap ; rc.nb_pts = (long) (1 + params->x2 - params->x1) ; is_15bits = Vapi->RaIs15Bits() ; if ( img->fd_nplanes == 16 ) { nb_bits_red = 5 ; nb_bits_green = is_15bits ? 5:6 ; nb_bits_blue = 5 ; } /* Remet a jour les precalculs de pourcentage sur les composantes si necessaire */ if ( rgamma != gamma_red ) ChangeColors( rgamma, RedRemap, nb_bits_red ) ; if ( ggamma != gamma_green ) ChangeColors( ggamma, GreenRemap, nb_bits_green ) ; if ( bgamma != gamma_blue ) ChangeColors( bgamma, BlueRemap, nb_bits_blue ) ; nb_pts_in_line = ALIGN16(img->fd_w) ; pt_line16 = (short *) img->fd_addr ; pt_line16 += (long)(params->y1) * nb_pts_in_line ; pt_line16 += params->x1 ; pt_line32 = (long *) img->fd_addr ; pt_line32 += (long)(params->y1) * nb_pts_in_line ; pt_line32 += params->x1 ; for ( y = params->y1; !cancel && (y <= params->y2); y++ ) { if ( img->fd_nplanes == 16 ) { rc.pt_img = pt_line16 ; pt_line16 += nb_pts_in_line ; if ( is_15bits ) Vapi->RaTC15RemapColors( &rc ) ; else Vapi->RaTC16RemapColors( &rc ) ; } else { rc.pt_img = pt_line32 ; pt_line32 += nb_pts_in_line ; Vapi->RaTC32RemapColors( &rc ) ; } if ( ( y & 0x0F ) == 0x0F ) { pc = (short) ( ( 100L * (long)(y - params->y1) ) / (long)(params->y2 - params->y1) ) ; cancel = Vapi->PrSetProgEx( pc ) ; } } } gamma_red = rgamma ; gamma_green = ggamma ; gamma_blue = bgamma ; return( cancel ? ELDV_CANCELLED : ELDV_NOERROR ) ; }