📄 _ocr_example_image_view_8cpp-source.html
字号:
<a name="l00237"></a>00237 <a name="l00238"></a>00238 <span class="comment">// -----------------------------------------------------------------------------</span><a name="l00239"></a>00239 <span class="comment">// COcrExampleImageView::HandleSizeChange</span><a name="l00240"></a>00240 <span class="comment">// Handle screen size change.</span><a name="l00241"></a>00241 <span class="comment">// -----------------------------------------------------------------------------</span><a name="l00242"></a>00242 <span class="comment">//</span><a name="l00243"></a><a class="code" href="class_c_ocr_example_image_view.html#04bbd31ba9f2f99b17c69030e5cf96cb">00243</a> <span class="keywordtype">void</span> <a class="code" href="class_c_ocr_example_image_view.html#04bbd31ba9f2f99b17c69030e5cf96cb">COcrExampleImageView::HandleSizeChange</a>()<a name="l00244"></a>00244 {<a name="l00245"></a>00245 <span class="keywordflow">if</span> (<a class="code" href="class_c_ocr_example_image_view.html#6dc94c8cd7c107bc61701348814020e6">iContainer</a>)<a name="l00246"></a>00246 {<a name="l00247"></a>00247 TRect mainPaneRect;<a name="l00248"></a>00248 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);<a name="l00249"></a>00249 <a name="l00250"></a>00250 <span class="comment">// if image is loaded, re-scale it</span><a name="l00251"></a>00251 <span class="keywordflow">if</span> ((<a class="code" href="class_c_ocr_example_image_view.html#56132cb68e64726ad0658571e44e9644">iHandler</a>) && (<a class="code" href="class_c_ocr_example_image_view.html#9eb6fa3188758350a81b83400892e787">iBitMap</a>))<a name="l00252"></a>00252 {<a name="l00253"></a>00253 TRAP_IGNORE(<a class="code" href="class_c_ocr_example_image_view.html#56132cb68e64726ad0658571e44e9644">iHandler</a>-><a class="code" href="class_n_o_c_r_utils_1_1_c_image_handler.html#5321ab83edffb2d7f3815c37aaaaad51">FitToScreenL</a>( mainPaneRect.Size() ));<a name="l00254"></a>00254 }<a name="l00255"></a>00255 <a name="l00256"></a>00256 <a class="code" href="class_c_ocr_example_image_view.html#6dc94c8cd7c107bc61701348814020e6">iContainer</a>->SetRect(mainPaneRect);<a name="l00257"></a>00257 }<a name="l00258"></a>00258 }<a name="l00259"></a>00259 <a name="l00260"></a>00260 <span class="comment">// ----------------------------------------------------------------------------</span><a name="l00261"></a>00261 <span class="comment">// COcrExampleImageView::ImageOperationCompleteL()</span><a name="l00262"></a>00262 <span class="comment">// callback function called by ImageHandler, when an image has been loaded or</span><a name="l00263"></a>00263 <span class="comment">// scaled</span><a name="l00264"></a>00264 <span class="comment">// ----------------------------------------------------------------------------</span><a name="l00265"></a>00265 <span class="comment">//</span><a name="l00266"></a><a class="code" href="class_c_ocr_example_image_view.html#09a548f36fef23b5490ecdf57e2bdd1a">00266</a> <span class="keywordtype">void</span> <a class="code" href="class_c_ocr_example_image_view.html#09a548f36fef23b5490ecdf57e2bdd1a">COcrExampleImageView::ImageOperationCompleteL</a>(TInt aError)<a name="l00267"></a>00267 {<a name="l00268"></a>00268 <a class="code" href="class_c_ocr_example_image_view.html#a7f5826c4c1c2cbee83739946a8a013b">iBackgroundTaskDone</a> = ETrue; <span class="comment">// to dismiss wait-note</span><a name="l00269"></a>00269 <span class="keywordflow">if</span> (aError)<a name="l00270"></a>00270 {<a name="l00271"></a>00271 _LIT(KFailed,<span class="stringliteral">"Loading/scaling image failed"</span>);<a name="l00272"></a>00272 <a class="code" href="class_c_ocr_example_image_view.html#5d97b3005d7025da3ce0f8f008328e43">DisplayWarningL</a>(KFailed, aError);<a name="l00273"></a>00273 }<a name="l00274"></a>00274 <span class="keywordflow">else</span><a name="l00275"></a>00275 {<a name="l00276"></a>00276 <span class="comment">// we should now have the image and also another one (resized to fit</span><a name="l00277"></a>00277 <span class="comment">// the screen). Calculate the factors (needed later, when adjusting</span><a name="l00278"></a>00278 <span class="comment">// TRect-info analyzed from the original image)</span><a name="l00279"></a>00279 <span class="comment">//</span><a name="l00280"></a>00280 <a class="code" href="class_c_ocr_example_image_view.html#e72899bf23845a10c6b7559c2e896baa">iData</a>.<a class="code" href="class_t_screen_update_data.html#d8df217ecaec20976c2b240f971a5034">iRectScaler</a>.<a class="code" href="class_n_o_c_r_utils_1_1_t_rect_scaler.html#a6b4fc57b5dda0378f9f21a73f7bdb13">CalculateFactor</a>(<a class="code" href="class_c_ocr_example_image_view.html#9eb6fa3188758350a81b83400892e787">iBitMap</a>->SizeInPixels(),<a name="l00281"></a>00281 <a class="code" href="class_c_ocr_example_image_view.html#e72899bf23845a10c6b7559c2e896baa">iData</a>.<a class="code" href="class_t_screen_update_data.html#ea6eefa2a3b0315b12fbb5ab0532a849">iScaledBitMap</a>->SizeInPixels());<a name="l00282"></a>00282 <span class="keywordflow">if</span> (<a class="code" href="class_c_ocr_example_image_view.html#63052a309baec315239b427aa7647b76">iState</a> == <a class="code" href="class_c_ocr_example_image_view.html#8e0e9e3030ee220d737a3e9e733390ec553253ec36b6a826ce4923c5dcf95a12">EInit</a>)<a name="l00283"></a>00283 {<a name="l00284"></a>00284 <a class="code" href="class_c_ocr_example_image_view.html#63052a309baec315239b427aa7647b76">iState</a> = <a class="code" href="class_c_ocr_example_image_view.html#8e0e9e3030ee220d737a3e9e733390ecc7b1c96e80ea74eab865de4fc9f448ea">EImageOpened</a>;<a name="l00285"></a>00285 }<a name="l00286"></a>00286 <a class="code" href="class_c_ocr_example_image_view.html#6dc94c8cd7c107bc61701348814020e6">iContainer</a>->DrawDeferred();<a name="l00287"></a>00287 }<a name="l00288"></a>00288 }<a name="l00289"></a>00289 <a name="l00290"></a><a class="code" href="class_c_ocr_example_image_view.html#3a8345b1114dbca51373caaf97b3bd53">00290</a> <span class="keywordtype">void</span> <a class="code" href="class_c_ocr_example_image_view.html#3a8345b1114dbca51373caaf97b3bd53">COcrExampleImageView::DialogDismissedL</a>(TInt <span class="comment">/*aButtonId*/</span>)<a name="l00291"></a>00291 {<a name="l00292"></a>00292 <span class="comment">// no implementation needed</span><a name="l00293"></a>00293 }<a name="l00294"></a>00294 <a name="l00295"></a><a class="code" href="class_c_ocr_example_image_view.html#34fc7596f70aed6415e69cc09bec0968">00295</a> TBool <a class="code" href="class_c_ocr_example_image_view.html#34fc7596f70aed6415e69cc09bec0968">COcrExampleImageView::IsProcessDone</a>()<span class="keyword"> const</span><a name="l00296"></a>00296 <span class="keyword"> </span>{<a name="l00297"></a>00297 <span class="keywordflow">return</span> <a class="code" href="class_c_ocr_example_image_view.html#a7f5826c4c1c2cbee83739946a8a013b">iBackgroundTaskDone</a>;<a name="l00298"></a>00298 }<a name="l00299"></a>00299 <a name="l00300"></a><a class="code" href="class_c_ocr_example_image_view.html#9fadb422c50df5ad198f645d92cf408c">00300</a> <span class="keywordtype">void</span> <a class="code" href="class_c_ocr_example_image_view.html#9fadb422c50df5ad198f645d92cf408c">COcrExampleImageView::ProcessFinished</a>()<a name="l00301"></a>00301 {<a name="l00302"></a>00302 <a class="code" href="class_c_ocr_example_image_view.html#a7f5826c4c1c2cbee83739946a8a013b">iBackgroundTaskDone</a> = EFalse;<a name="l00303"></a>00303 }<a name="l00304"></a>00304 <a name="l00305"></a><a class="code" href="class_c_ocr_example_image_view.html#2b047861e8a98fc470be28703b1bd9d0">00305</a> <span class="keywordtype">void</span> <a class="code" href="class_c_ocr_example_image_view.html#2b047861e8a98fc470be28703b1bd9d0">COcrExampleImageView::StepL</a>()<a name="l00306"></a>00306 {<a name="l00307"></a>00307 <span class="comment">// no implementation needed</span><a name="l00308"></a>00308 }<a name="l00309"></a>00309 <a name="l00310"></a><a class="code" href="class_c_ocr_example_image_view.html#41df03d3f25580af9a93f5af442ce677">00310</a> TBool <a class="code" href="class_c_ocr_example_image_view.html#41df03d3f25580af9a93f5af442ce677">COcrExampleImageView::ExecuteWaitNoteL</a>()<a name="l00311"></a>00311 {<a name="l00312"></a>00312 CAknWaitNoteWrapper* waitNote = CAknWaitNoteWrapper::NewL();<a name="l00313"></a>00313 <a name="l00314"></a>00314 <span class="comment">// Required reinterpret_cast as CAknWaitNoteWrapper inherits privately</span><a name="l00315"></a>00315 <span class="comment">// from CActive</span><a name="l00316"></a>00316 CleanupStack::PushL(reinterpret_cast<CBase*>(waitNote));<a name="l00317"></a>00317 <a name="l00318"></a>00318 <span class="comment">// this is a blocking call</span><a name="l00319"></a>00319 TBool completed = waitNote->ExecuteL(R_OCR_WAITNOTE, *<span class="keyword">this</span>);<a name="l00320"></a>00320 <a name="l00321"></a>00321 CleanupStack::PopAndDestroy(waitNote);<a name="l00322"></a>00322 <a name="l00323"></a>00323 <span class="keywordflow">return</span> completed;<a name="l00324"></a>00324 }<a name="l00325"></a>00325 <a name="l00326"></a>00326 <span class="comment">// -----------------------------------------------------------------------------</span><a name="l00327"></a>00327 <span class="comment">// COcrExampleImageView::DisplayWarningL()</span><a name="l00328"></a>00328 <span class="comment">// -----------------------------------------------------------------------------</span><a name="l00329"></a>00329 <span class="comment">//</span><a name="l00330"></a><a class="code" href="class_c_ocr_example_image_view.html#5d97b3005d7025da3ce0f8f008328e43">00330</a> <span class="keywordtype">void</span> <a class="code" href="class_c_ocr_example_image_view.html#5d97b3005d7025da3ce0f8f008328e43">COcrExampleImageView::DisplayWarningL</a>( <span class="keyword">const</span> TDesC &aDescr, TInt aErr)<span class="keyword"> const</span><a name="l00331"></a>00331 <span class="keyword"> </span>{<a name="l00332"></a>00332 ASSERT( aErr != KErrNone );<a name="l00333"></a>00333 <a name="l00334"></a>00334 _LIT(KFailed,<span class="stringliteral">"%S: %d"</span>);<a name="l00335"></a>00335 CAknWarningNote* note = <span class="keyword">new</span> (ELeave) CAknWarningNote(ETrue);<a name="l00336"></a>00336 TBuf<128> text;<a name="l00337"></a>00337 text.Format(KFailed, &aDescr, aErr);<a name="l00338"></a>00338 note->ExecuteLD( text );<a name="l00339"></a>00339 }<a name="l00340"></a>00340 <a name="l00341"></a>00341 <span class="comment">// -----------------------------------------------------------------------------</span><a name="l00342"></a>00342 <span class="comment">// COcrExampleImageView::OpenImageL()</span><a name="l00343"></a>00343 <span class="comment">// -----------------------------------------------------------------------------</span><a name="l00344"></a>00344 <span class="comment">//</span><a name="l00345"></a><a class="code" href="class_c_ocr_example_image_view.html#2003512dd8696219849f58d8ae1e3c37">00345</a> <span class="keywordtype">void</span> <a class="code" href="class_c_ocr_example_image_view.html#2003512dd8696219849f58d8ae1e3c37">COcrExampleImageView::OpenImageL</a>()<a name="l00346"></a>00346 {<a name="l00347"></a>00347 <span class="comment">// use dialog</span><a name="l00348"></a>00348 _LIT(KTitle, <span class="stringliteral">"Select image file"</span>);<a name="l00349"></a>00349 TFileName file(KNullDesC);<a name="l00350"></a>00350 <span class="keywordflow">if</span> (AknCommonDialogs::RunSelectDlgLD(file, R_OCR_SELECT_DIALOG, KTitle))<a name="l00351"></a>00351 {<a name="l00352"></a>00352 <span class="comment">// close possible previously loaded image</span><a name="l00353"></a>00353 <a class="code" href="class_c_ocr_example_image_view.html#7561e6dda22ddb24f4b8c58d0229ebc5">CloseImage</a>();<a name="l00354"></a>00354 <a name="l00355"></a>00355 TRect mainPaneRect;<a name="l00356"></a>00356 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);<a name="l00357"></a>00357 TRAPD(err, <a class="code" href="class_c_ocr_example_image_view.html#56132cb68e64726ad0658571e44e9644">iHandler</a>-><a class="code" href="class_n_o_c_r_utils_1_1_c_image_handler.html#0135e243bf1c2ba8db5d62edc631e3d4">LoadFileAndScaleL</a>( file, mainPaneRect.Size() ));<a name="l00358"></a>00358 <span class="keywordflow">if</span> (err)<a name="l00359"></a>00359 {<a name="l00360"></a>00360 _LIT(KFileLoadFailed,<span class="stringliteral">"Opening image file failed"</span>);<a name="l00361"></a>00361 <a class="code" href="class_c_ocr_example_image_view.html#5d97b3005d7025da3ce0f8f008328e43">DisplayWarningL</a>(KFileLoadFailed, err);<a name="l00362"></a>00362 }<a name="l00363"></a>00363 <span class="keywordflow">else</span><a name="l00364"></a>00364 {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -