1 /****************************************************************************
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the utility applications of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** No Commercial Usage
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
18 ** General Public License version 2.1 as published by the Free Software
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
20 ** packaging of this file. Please review the following information to
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 ** In addition, as a special exception, Nokia gives you certain additional
25 ** rights. These rights are described in the Nokia Qt LGPL Exception
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
40 ****************************************************************************/
46 #include "pm_mapper.hrh"
47 #include "pm_mapperapp.h"
48 #include "pm_mapperview.h"
49 #include <pm_mapper.rsg>
51 #include <BldVariant.hrh>
62 #include <aknnotedialog.h>
63 #include <stringloader.h>
64 #include <coneresloader.h>
65 #include <aknglobalnote.h>
67 #include <CentralRepository.h>
68 #include <AvkonInternalCRKeys.h> // KAknLayoutId
70 #include <Aknsutils.h>
72 #include "pixel_metrics.h"
76 #include <AknLayoutConfig.h>
79 typedef TBuf
<2048> TMySmallBuffer
;
80 typedef TBuf
<8192> TMyBigBuffer
;
82 _LIT(KLayoutSourceFileAndPath
, "\\private\\2002121f\\pm_layout.cpp");
83 _LIT(KPixelMetricsDataFiles
, "\\private\\2002121f\\*.txt");
84 _LIT(KOpenBrace
, "{");
88 _LIT(KEndBraceWithCommaAndCRLF
, "},\n");
91 // Number of header lines in layout data.
92 const TInt KHeaderValues
= 5;
94 // ============================ MEMBER FUNCTIONS ===============================
96 // -----------------------------------------------------------------------------
97 // C++ constructor can NOT contain any code, that
99 // -----------------------------------------------------------------------------
101 CPixelMetricsMapperAppUi::CPixelMetricsMapperAppUi() : iFileOutputOn(EFalse
)
105 // -----------------------------------------------------------------------------
107 // -----------------------------------------------------------------------------
109 CPixelMetricsMapperAppUi::~CPixelMetricsMapperAppUi()
113 // -----------------------------------------------------------------------------
114 // Symbian 2nd phase constructor can leave.
115 // -----------------------------------------------------------------------------
117 void CPixelMetricsMapperAppUi::ConstructL()
121 CEikonEnv
& eikEnv
= *CEikonEnv::Static();
123 eikEnv
.WsSession().ComputeMode(
124 RWsSession::EPriorityControlDisabled
);
125 RThread().SetProcessPriority( EPriorityHigh
);
127 CPixelMetricsMapperView
* view
= new( ELeave
) CPixelMetricsMapperView
;
128 CleanupStack::PushL( view
);
130 CleanupStack::Pop(); // view
131 AddViewL(view
); // transfer ownership to CAknViewAppUi
135 // -----------------------------------------------------------------------------
137 // -----------------------------------------------------------------------------
139 TKeyResponse
CPixelMetricsMapperAppUi::HandleKeyEventL(
140 const TKeyEvent
& /*aKeyEvent*/,
141 TEventCode
/*aType*/ )
143 return EKeyWasNotConsumed
;
146 // -----------------------------------------------------------------------------
148 // -----------------------------------------------------------------------------
150 void CPixelMetricsMapperAppUi::HandleCommandL( TInt aCommand
)
154 case EAknSoftkeyExit
:
158 case ECmdSwitchOutput
:
159 iFileOutputOn
= !iFileOutputOn
;
166 CRepository
* repository
= NULL
;
167 TInt value
= KErrNotFound
;
168 TRAPD(ret
, repository
= CRepository::NewL(KCRUidAvkon
));
171 ret
= repository
->Get(KAknLayoutId
, value
);
175 HBufC
* buffer
= HBufC::NewLC( 100 );
176 TPtr bufferPtr
= buffer
->Des();
177 bufferPtr
.Append(_L("Layout: "));
180 bufferPtr
.AppendNum(value
);
184 bufferPtr
.Append(_L("(error) "));
185 bufferPtr
.AppendNum(ret
);
188 ShowL( *buffer
, last
);
192 bufferPtr
.Append(_L("Orientation: "));
193 bufferPtr
.AppendNum((TInt
)iAvkonAppUi
->Orientation());
194 ShowL( *buffer
, last
);
198 bufferPtr
.Append(_L("Output: "));
199 if (iFileOutputOn
) bufferPtr
.Append(_L("File"));
200 else bufferPtr
.Append(_L("Screen"));
201 ShowL( *buffer
, last
);
205 bufferPtr
.Append(_L("AutoMode: "));
206 bufferPtr
.AppendNum((TInt
)iAutoMode
);
207 ShowL( *buffer
, last
);
210 CAknLayoutConfig::TScreenMode localAppScreenMode
= CAknSgcClient::ScreenMode();
211 TInt hashValue
= localAppScreenMode
.ScreenStyleHash();
212 TPixelsTwipsAndRotation pixels
= CAknSgcClient::PixelsAndRotation();
213 TSize pixelSize
= pixels
.iPixelSize
;
215 bufferPtr
.Append(_L("LayoutName: "));
217 if ( (pixelSize
.iWidth
== 320 || pixelSize
.iWidth
== 240 )&&
218 (pixelSize
.iHeight
== 320 || pixelSize
.iHeight
== 240 ))
220 if (hashValue
==0x996F7AA7)
221 bufferPtr
.Append(_L("QVGA2"));
223 bufferPtr
.Append(_L("QVGA1"));
225 else if ((pixelSize
.iWidth
== 640 || pixelSize
.iWidth
== 360 )&&
226 (pixelSize
.iHeight
== 360 || pixelSize
.iHeight
== 640 ))
228 bufferPtr
.Append(_L("nHD"));
230 else if ((pixelSize
.iWidth
== 640 || pixelSize
.iWidth
== 480 )&&
231 (pixelSize
.iHeight
== 480 || pixelSize
.iHeight
== 640 ))
233 bufferPtr
.Append(_L("VGA"));
235 else if ((pixelSize
.iWidth
== 352 || pixelSize
.iWidth
== 800 )&&
236 (pixelSize
.iHeight
== 800 || pixelSize
.iHeight
== 352 ))
238 bufferPtr
.Append(_L("E90"));
240 else if ((pixelSize
.iWidth
== 320 || pixelSize
.iWidth
== 480 ||
241 pixelSize
.iWidth
== 240 || pixelSize
.iWidth
== 640 )&&
242 (pixelSize
.iHeight
== 320 || pixelSize
.iHeight
== 480 ||
243 pixelSize
.iHeight
== 240 || pixelSize
.iHeight
== 640))
245 bufferPtr
.Append(_L("HVGA"));
247 else if ((pixelSize
.iWidth
== 480 || pixelSize
.iWidth
== 854 ||
248 pixelSize
.iWidth
== 848 || pixelSize
.iWidth
== 800 )&&
249 (pixelSize
.iHeight
== 800 || pixelSize
.iHeight
== 480 ||
250 pixelSize
.iHeight
== 848 || pixelSize
.iHeight
== 854))
252 bufferPtr
.Append(_L("WVGA"));
256 bufferPtr
.Append(_L("Unknown"));
259 ShowL( *buffer
, last
);
261 CleanupStack::PopAndDestroy( buffer
);
264 case ECmdSwitchMirroring
:
266 // set the shared data value
267 CRepository
* repository
= NULL
;
268 TRAPD(ret
, repository
= CRepository::NewL(KCRUidAvkon
));
271 TInt value
= KErrNotFound
;
272 repository
->Get(KAknLayoutId
, value
);
273 if ( value
== EAknLayoutIdELAF
)
275 value
= EAknLayoutIdABRW
;
277 else if (value
==EAknLayoutIdABRW
)
279 value
= EAknLayoutIdELAF
;
281 ret
= repository
->Set(KAknLayoutId
, value
);
284 // now inform all open apps of the switch
286 event
.SetType(KEikDynamicLayoutVariantSwitch
);
287 iEikonEnv
->WsSession().SendEventToAllWindowGroups(event
);
290 case ECmdSwitchOrientation
:
293 #ifndef __SERIES60_31__
294 if (!iAvkonAppUi
->OrientationCanBeChanged())
296 HBufC
* buffer
= HBufC::NewLC( 100 );
297 TPtr bufferPtr
= buffer
->Des();
298 bufferPtr
.Append(_L("Orientation cannot be changed."));
300 ShowL( *buffer
, last
);
304 #endif //__SERIES60_31__
305 if ( iAvkonAppUi
->Orientation() == CAknAppUiBase::EAppUiOrientationPortrait
)
307 iAvkonAppUi
->SetOrientationL(CAknAppUiBase::EAppUiOrientationLandscape
);
309 else if (iAvkonAppUi
->Orientation() == CAknAppUiBase::EAppUiOrientationLandscape
)
311 iAvkonAppUi
->SetOrientationL(CAknAppUiBase::EAppUiOrientationPortrait
);
316 iAvkonAppUi
->SetOrientationL(CAknAppUiBase::EAppUiOrientationLandscape
);
317 /*User::After(100000);
318 HBufC* buffer = HBufC::NewLC( 100 );
319 TPtr bufferPtr = buffer->Des();
320 bufferPtr.Append(_L("Orientation unspecified."));
322 ShowL( *buffer, last );
328 case ECmdStartCalculations
:
337 AknLayoutUtils::LayoutMetricsRect(
338 AknLayoutUtils::EApplicationWindow
,
341 // Add screen dimensions
342 TInt height
= screenRect
.Height();
343 TInt width
= screenRect
.Width();
346 tgt
.Append(_L("height: \t"));
347 tgt
.AppendNum(height
, EDecimal
); // put max height into text file
351 tgt
.Append(_L("width: \t"));
352 tgt
.AppendNum(width
, EDecimal
); // put max width into text file
356 TPixelMetricsVersion version
= PixelMetrics::Version();
357 tgt
.Append(_L("major_version: \t"));
358 tgt
.AppendNum(version
.majorVersion
, EDecimal
); // put major version into text file
361 tgt
.Append(_L("minor_version: \t"));
362 tgt
.AppendNum(version
.minorVersion
, EDecimal
); // put minor version into text file
366 TBool mirrored
= AknLayoutUtils::LayoutMirrored();
367 tgt
.Append(_L("mirrored: \t"));
368 tgt
.AppendNum(mirrored
, EDecimal
); // put mirrored state into text file
373 TInt myValue
= KErrNotFound
;
376 if (index
==QStyle::PM_Custom_ThinLineWidth
)
380 myValue
= PixelMetrics::PixelMetricValue(static_cast<QStyle::PixelMetric
>(index
));
381 ShowSingleValueL( index
, myValue
, last
);
384 // if last before custom values, "jump" to custom base
385 if (index
==QStyle::PM_SubMenuOverlap
) index
= QStyle::PM_CustomBase
;
388 if (iAutoMode
&& !iMode
)
390 HandleCommandL(ECmdSwitchMirroring
);
395 case ECmdCreateHeaderFile
:
398 case ECmdSetAutoMode
:
399 iAutoMode
= !iAutoMode
;
404 void CPixelMetricsMapperAppUi::DoAutoOperationL()
406 HandleCommandL(ECmdStartCalculations
);
408 HandleCommandL(ECmdSwitchMirroring
);
411 TBool
CPixelMetricsMapperAppUi::ReadyForAutoOp() const
413 return (iAutoMode
&& iMode
);
416 // -----------------------------------------------------------------------------
418 // -----------------------------------------------------------------------------
420 void CPixelMetricsMapperAppUi::ShowL( const TDesC
& aText
, TBool
& aLast
, const TBool
& aFileOutput
)
422 _LIT( KTestPrefix
, "\t" );
424 HBufC
* buffer
= HBufC::NewLC( aText
.Length() + KTestPrefix().Length() );
425 TPtr ptr
= buffer
->Des();
426 ptr
.Append( KTestPrefix
);
428 iView
->ShowL( *buffer
, aLast
, aFileOutput
);
429 CleanupStack::PopAndDestroy( buffer
);
432 void CPixelMetricsMapperAppUi::ShowSingleValueL(TInt
& aPixelMetric
, TInt
& aValue
, TBool
& aLast
)
434 HBufC
* buffer
= HBufC::NewLC( 100 );
435 TPtr bufferPtr
= buffer
->Des();
437 switch (aPixelMetric
)
439 case QStyle::PM_DockWidgetTitleMargin
:
440 bufferPtr
.Append(_L("DockTitleMargin: "));
442 case QStyle::PM_DockWidgetTitleBarButtonMargin
:
443 bufferPtr
.Append(_L("DockTitleBtnMargin: "));
445 case QStyle::PM_ButtonMargin
:
446 bufferPtr
.Append(_L("ButtonMargin: "));
448 case QStyle::PM_ButtonDefaultIndicator
:
449 bufferPtr
.Append(_L("ButtonDefaultIndicator: "));
451 case QStyle::PM_MdiSubWindowFrameWidth
:
452 bufferPtr
.Append(_L("MdiSubWndFrameW: "));
454 case QStyle::PM_ComboBoxFrameWidth
:
455 bufferPtr
.Append(_L("ComboBoxFrameWidth: "));
457 case QStyle::PM_SpinBoxFrameWidth
:
458 bufferPtr
.Append(_L("SpinBoxFrameWidth: "));
460 case QStyle::PM_DefaultFrameWidth
:
461 bufferPtr
.Append(_L("DefaultFrameWidth: "));
463 case QStyle::PM_RadioButtonLabelSpacing
:
464 bufferPtr
.Append(_L("RadioButtonLabelSpc: "));
466 case QStyle::PM_CheckBoxLabelSpacing
:
467 bufferPtr
.Append(_L("CheckBoxLabelSpacing: "));
469 case QStyle::PM_ToolTipLabelFrameWidth
:
470 bufferPtr
.Append(_L("ToolTipLabelFrameW: "));
472 case QStyle::PM_ListViewIconSize
:
473 bufferPtr
.Append(_L("ListViewIconSize: "));
475 case QStyle::PM_LargeIconSize
:
476 bufferPtr
.Append(_L("LargeIconSize: "));
478 case QStyle::PM_IconViewIconSize
:
479 bufferPtr
.Append(_L("IconViewIconSize: "));
481 case QStyle::PM_TabBarIconSize
:
482 bufferPtr
.Append(_L("TabBarIconSize: "));
484 case QStyle::PM_MessageBoxIconSize
:
485 bufferPtr
.Append(_L("MessageBoxIconSize: "));
487 case QStyle::PM_ButtonIconSize
:
488 bufferPtr
.Append(_L("ButtonIconSize: "));
490 case QStyle::PM_TextCursorWidth
:
491 bufferPtr
.Append(_L("TextCursorWidth: "));
493 case QStyle::PM_SliderLength
:
494 bufferPtr
.Append(_L("SliderLength: "));
496 case QStyle::PM_SliderThickness
:
497 bufferPtr
.Append(_L("SliderThickness: "));
499 case QStyle::PM_SliderTickmarkOffset
:
500 bufferPtr
.Append(_L("SliderTickmarkOffset: "));
502 case QStyle::PM_SliderControlThickness
:
503 bufferPtr
.Append(_L("SliderCntrlThickness: "));
505 case QStyle::PM_SliderSpaceAvailable
:
506 bufferPtr
.Append(_L("SliderSpaceAvailable: "));
508 case QStyle::PM_MenuBarItemSpacing
:
509 bufferPtr
.Append(_L("MenuBarItemSpacing: "));
511 case QStyle::PM_MenuBarHMargin
:
512 bufferPtr
.Append(_L("MenuBarHMargin: "));
514 case QStyle::PM_MenuBarVMargin
:
515 bufferPtr
.Append(_L("MenuBarVMargin: "));
517 case QStyle::PM_ToolBarItemSpacing
:
518 bufferPtr
.Append(_L("ToolBarItemSpacing: "));
520 case QStyle::PM_ToolBarFrameWidth
:
521 bufferPtr
.Append(_L("ToolBarFrameWidth: "));
523 case QStyle::PM_ToolBarItemMargin
:
524 bufferPtr
.Append(_L("ToolBarItemMargin: "));
526 case QStyle::PM_LayoutLeftMargin
:
527 bufferPtr
.Append(_L("LayoutLeftMargin: "));
529 case QStyle::PM_LayoutRightMargin
:
530 bufferPtr
.Append(_L("LayoutRightMargin: "));
532 case QStyle::PM_LayoutTopMargin
:
533 bufferPtr
.Append(_L("LayoutTopMargin: "));
535 case QStyle::PM_LayoutBottomMargin
:
536 bufferPtr
.Append(_L("LayoutBottomMargin: "));
538 case QStyle::PM_LayoutHorizontalSpacing
:
539 bufferPtr
.Append(_L("LayoutHSpacing: "));
541 case QStyle::PM_LayoutVerticalSpacing
:
542 bufferPtr
.Append(_L("LayoutVSpacing: "));
544 case QStyle::PM_MaximumDragDistance
:
545 bufferPtr
.Append(_L("MaxDragDistance: "));
547 case QStyle::PM_ScrollBarExtent
:
548 bufferPtr
.Append(_L("ScrollBarExtent: "));
550 case QStyle::PM_ScrollBarSliderMin
:
551 bufferPtr
.Append(_L("ScrollBarSliderMin: "));
553 case QStyle::PM_MenuBarPanelWidth
:
554 bufferPtr
.Append(_L("MenuBarPanelWidth: "));
556 case QStyle::PM_ProgressBarChunkWidth
:
557 bufferPtr
.Append(_L("ProgBarChunkWidth: "));
559 case QStyle::PM_TabBarTabOverlap
:
560 bufferPtr
.Append(_L("TabBarTabOverlap: "));
562 case QStyle::PM_TabBarTabHSpace
:
563 bufferPtr
.Append(_L("TabBarTabHSpace: "));
565 case QStyle::PM_TabBarTabVSpace
:
566 bufferPtr
.Append(_L("TabBarTabVSpace: "));
568 case QStyle::PM_TabBarBaseHeight
:
569 bufferPtr
.Append(_L("TabBarBaseHeight: "));
571 case QStyle::PM_TabBarBaseOverlap
:
572 bufferPtr
.Append(_L("TabBarBaseOverlap: "));
574 case QStyle::PM_TabBarScrollButtonWidth
:
575 bufferPtr
.Append(_L("TabBarScrollBtnWidth: "));
577 case QStyle::PM_TabBarTabShiftHorizontal
:
578 bufferPtr
.Append(_L("TabBarTabShiftH: "));
580 case QStyle::PM_TabBarTabShiftVertical
:
581 bufferPtr
.Append(_L("TabBarTabShiftV: "));
583 case QStyle::PM_MenuPanelWidth
:
584 bufferPtr
.Append(_L("MenuPanelWidth: "));
586 case QStyle::PM_MenuHMargin
:
587 bufferPtr
.Append(_L("MenuHMargin: "));
589 case QStyle::PM_MenuVMargin
:
590 bufferPtr
.Append(_L("MenuVMargin: "));
592 case QStyle::PM_MenuDesktopFrameWidth
:
593 bufferPtr
.Append(_L("MenuFrameWidth: "));
595 case QStyle::PM_SmallIconSize
:
596 bufferPtr
.Append(_L("SmallIconSize: "));
598 case QStyle::PM_FocusFrameHMargin
:
599 bufferPtr
.Append(_L("FocusFrameHMargin: "));
601 case QStyle::PM_FocusFrameVMargin
:
602 bufferPtr
.Append(_L("FocusFrameVMargin: "));
604 case QStyle::PM_ToolBarIconSize
:
605 bufferPtr
.Append(_L("ToolBarIconSize: "));
607 case QStyle::PM_TitleBarHeight
: // use titlepane height
608 bufferPtr
.Append(_L("TitleBarHeight: "));
610 case QStyle::PM_IndicatorWidth
:
611 bufferPtr
.Append(_L("IndicatorWidth: "));
613 case QStyle::PM_IndicatorHeight
:
614 bufferPtr
.Append(_L("IndicatorHeight: "));
616 case QStyle::PM_ExclusiveIndicatorHeight
:
617 bufferPtr
.Append(_L("ExclusiveIndHeight: "));
619 case QStyle::PM_ExclusiveIndicatorWidth
:
620 bufferPtr
.Append(_L("ExclusiveIndWidth: "));
622 case QStyle::PM_HeaderMargin
: // not in S60
623 bufferPtr
.Append(_L("HeaderMargin: "));
625 case QStyle::PM_MenuScrollerHeight
: // not in S60
626 bufferPtr
.Append(_L("MenuScrollerHeight: "));
628 case QStyle::PM_MenuTearoffHeight
: // not in S60
629 bufferPtr
.Append(_L("MenuTearoffHeight: "));
631 case QStyle::PM_DockWidgetFrameWidth
: // not in S60
632 bufferPtr
.Append(_L("DockFrameWidth: "));
634 case QStyle::PM_DockWidgetSeparatorExtent
: // not in S60
635 bufferPtr
.Append(_L("DockSepExtent: "));
637 case QStyle::PM_MdiSubWindowMinimizedWidth
: //no such thing in S60
638 bufferPtr
.Append(_L("MdiSubWndMinWidth: "));
640 case QStyle::PM_HeaderGripMargin
: // not in S60
641 bufferPtr
.Append(_L("HeaderGripMargin: "));
643 case QStyle::PM_SplitterWidth
: // not in S60
644 bufferPtr
.Append(_L("SplitterWidth: "));
646 case QStyle::PM_ToolBarExtensionExtent
: // not in S60
647 bufferPtr
.Append(_L("ToolBarExtExtent: "));
649 case QStyle::PM_ToolBarSeparatorExtent
: // not in S60
650 bufferPtr
.Append(_L("ToolBarSepExtent: "));
652 case QStyle::PM_ToolBarHandleExtent
: // not in s60
653 bufferPtr
.Append(_L("ToolBarHandleExtent: "));
655 case QStyle::PM_MenuButtonIndicator
: // none???
656 bufferPtr
.Append(_L("MenuButtonIndicator: "));
658 case QStyle::PM_ButtonShiftHorizontal
: //none in 3.x
659 bufferPtr
.Append(_L("ButtonShiftHorizontal: "));
661 case QStyle::PM_ButtonShiftVertical
: // none in 3.x
662 bufferPtr
.Append(_L("ButtonShiftVertical: "));
664 case QStyle::PM_TabBar_ScrollButtonOverlap
: // not used in S60 - tab arrows are on left and right side of tab group - not together
665 bufferPtr
.Append(_L("TabScrollBtnOverlap: "));
667 case QStyle::PM_SizeGripSize
: // use default
668 bufferPtr
.Append(_L("SizeGripSize: "));
670 case QStyle::PM_DockWidgetHandleExtent
:
671 bufferPtr
.Append(_L("DockWdgtHandleExt: "));
673 case QStyle::PM_CheckListButtonSize
:
674 bufferPtr
.Append(_L("CheckListButtonSize: "));
676 case QStyle::PM_CheckListControllerSize
:
677 bufferPtr
.Append(_L("CheckListCntlerSize: "));
679 case QStyle::PM_DialogButtonsSeparator
:
680 bufferPtr
.Append(_L("DialogBtnSeparator: "));
682 case QStyle::PM_DialogButtonsButtonWidth
:
683 bufferPtr
.Append(_L("DialogBtnWidth: "));
685 case QStyle::PM_DialogButtonsButtonHeight
:
686 bufferPtr
.Append(_L("DialogBtnHeight: "));
688 case QStyle::PM_HeaderMarkSize
:
689 bufferPtr
.Append(_L("HeaderMarkSize: "));
691 case QStyle::PM_SpinBoxSliderHeight
:
692 bufferPtr
.Append(_L("SpinBoxSliderHeight: "));
694 case QStyle::PM_DefaultTopLevelMargin
:
695 bufferPtr
.Append(_L("DefaultTopLvlMrg: "));
697 case QStyle::PM_DefaultChildMargin
:
698 bufferPtr
.Append(_L("DefaultChildMrg: "));
700 case QStyle::PM_DefaultLayoutSpacing
:
701 bufferPtr
.Append(_L("DefaultlayoutSpc: "));
703 case QStyle::PM_TabCloseIndicatorWidth
:
704 bufferPtr
.Append(_L("TabCloseIndWidth: "));
706 case QStyle::PM_TabCloseIndicatorHeight
:
707 bufferPtr
.Append(_L("TabCloseIndHeight: "));
709 case QStyle::PM_ScrollView_ScrollBarSpacing
:
710 bufferPtr
.Append(_L("ScrollViewBarSpc: "));
712 case QStyle::PM_SubMenuOverlap
:
713 bufferPtr
.Append(_L("SubMenuOverlap: "));
715 case QStyle::PM_Custom_FrameCornerHeight
:
716 bufferPtr
.Append(_L("C_FrCornerHeight: "));
718 case QStyle::PM_Custom_FrameCornerWidth
:
719 bufferPtr
.Append(_L("C_FrCornerWidth: "));
721 case QStyle::PM_Custom_ThinLineWidth
:
722 bufferPtr
.Append(_L("C_ThinLineWidth: "));
724 case QStyle::PM_Custom_BoldLineWidth
:
725 bufferPtr
.Append(_L("C_BoldLineWidth: "));
728 bufferPtr
.Append(_L("Default: "));
734 bufferPtr
.Append('\t');
736 bufferPtr
.AppendNum(aValue
);
737 bufferPtr
.Append(_L(" "));
738 ShowL( *buffer
, aLast
, iFileOutputOn
);
739 CleanupStack::PopAndDestroy( buffer
);
742 void CPixelMetricsMapperAppUi::ClearL()
747 void CPixelMetricsMapperAppUi::CreateHeaderFileL() const
749 // Open/create resulting file.
751 HBufC
* layoutFile
= HBufC::NewLC( KMaxFileName
);
752 *layoutFile
= KLayoutSourceFileAndPath
;
753 TFileName fileName
= *layoutFile
;
754 CleanupStack::PopAndDestroy(layoutFile
);
755 RFs
& fs
= CEikonEnv::Static()->FsSession();
756 TInt error
= file
.Open(fs
,fileName
, EFileWrite
|EFileShareAny
|EFileStreamText
);
757 if (error
==KErrNotFound
)
759 file
.Create(fs
,fileName
, EFileWrite
|EFileShareAny
|EFileStreamText
);
761 CleanupClosePushL( file
);
764 // Make all writes as from textfile.
766 textFile
.Set( file
);
767 textFile
.Seek( ESeekStart
);
769 // Take all layout files from private folder.
771 User::LeaveIfError(fs
.GetDir(
772 KPixelMetricsDataFiles
,
773 KEntryAttMaskSupported
,
777 TMySmallBuffer bufferLayoutHdr
;
778 TMyBigBuffer bufferPMData
;
779 TInt fileCount
= dirList
->Count();
780 for (TInt i
=0;i
<fileCount
;i
++)
784 TFileName layoutFile
= (*dirList
)[i
].iName
;
785 User::LeaveIfError( sourceFile
.Open(
786 fs
,layoutFile
, EFileRead
|EFileShareAny
|EFileStreamText
));
787 CleanupClosePushL( sourceFile
);
789 // Make all reads as from textfile.
790 TFileText textSourceFile
;
791 textSourceFile
.Set( sourceFile
);
792 TFileName layoutName
= CreateLayoutNameL( textSourceFile
);
794 // rewind - just in case.
795 textSourceFile
.Seek( ESeekStart
);
797 bufferLayoutHdr
.Append(KOpenBrace
);
798 bufferPMData
.Append(KOpenBrace
);
802 if( textSourceFile
.Read(oneline
) != KErrNone
)
806 // Add commas for all but first line
809 if ( loop
<= KHeaderValues
-1)
811 bufferLayoutHdr
.Append(KComma
);
815 if (loop
!= KHeaderValues
)
817 bufferPMData
.Append(KComma
);
820 if (loop
==KHeaderValues
)
822 bufferLayoutHdr
.Append(_L(",QLatin1String(\""));
823 bufferLayoutHdr
.Append(layoutName
);
824 bufferLayoutHdr
.Append(_L("\")"));
827 // Remove pixel metrics name and ":"
828 oneline
= oneline
.Mid(oneline
.Find(KColon
)+1);
830 oneline
= oneline
.Mid(oneline
.Find(KTab
)+1);
831 // remove crap from the end of line
833 TInt nextValue
= -666;
834 User::LeaveIfError( lex
.Val(nextValue
) );
835 if ( loop
<= KHeaderValues
-1)
837 if (loop
== KHeaderValues
-1 ) // true / false values
841 bufferLayoutHdr
.Append(_L("true"));
845 bufferLayoutHdr
.Append(_L("false"));
850 bufferLayoutHdr
.AppendNum(nextValue
);
855 if (nextValue
== -909)
856 bufferPMData
.Append(_L("ECommonStyleValue"));
858 bufferPMData
.AppendNum(nextValue
);
864 bufferLayoutHdr
.Append(KEndBraceWithCommaAndCRLF
);
865 bufferPMData
.Append(KEndBraceWithCommaAndCRLF
);
866 CleanupStack::PopAndDestroy(); //sourceFile
869 bufferLayoutHdr
= bufferLayoutHdr
.Left(bufferLayoutHdr
.Length()-2);
870 bufferPMData
= bufferPMData
.Left(bufferPMData
.Length()-2);
871 textFile
.Write(bufferLayoutHdr
);
872 textFile
.Write(KCRLF
);
873 textFile
.Write(bufferPMData
);
876 CleanupStack::PopAndDestroy(); //file
879 TFileName
CPixelMetricsMapperAppUi::CreateLayoutNameL(TFileText
& aFileHandle
) const
881 aFileHandle
.Seek(ESeekStart
);
882 // Layout data is deployed like this:
883 // first line - height
884 // second line - width
885 // fifth line mirror info
887 TFileName layoutName
;
891 TInt mirroring
= -666;
892 // Collect name information.
893 for (TInt i
=0; i
<6; i
++)
895 User::LeaveIfError(aFileHandle
.Read(lines
));
896 // Remove pixel metrics name and ":"
897 lines
= lines
.Mid(lines
.Find(KColon
)+1);
899 lines
= lines
.Mid(lines
.Find(KTab
)+1);
901 TInt error
= KErrNone
;
902 if (i
==0) //height is first
904 error
= myLexer
.Val(height
);
906 if (i
==1) //width is second
908 error
= myLexer
.Val(width
);
910 if (i
==4) //mirror info is fourth
912 error
= myLexer
.Val(mirroring
);
914 User::LeaveIfError(error
);
917 // Interpret results and write name to buffer.
918 if ( (width
== 240 && height
== 320) ||
919 (width
== 320 && height
== 240))
921 layoutName
.Append(_L("QVGA "));
923 else if ( (width
== 360 && height
== 640) ||
924 (width
== 640 && height
== 360))
926 layoutName
.Append(_L("NHD "));
928 else if ( (width
== 480 && height
== 640) ||
929 (width
== 640 && height
== 480))
931 layoutName
.Append(_L("VGA "));
933 else if ( (width
== 800 && height
== 352) ||
934 (width
== 352 && height
== 800))
936 layoutName
.Append(_L("E90 "));
938 else if ( (width
== 800 && height
== 480) ||
939 (width
== 480 && height
== 800) ||
940 (width
== 848 && height
== 480) ||
941 (width
== 480 && height
== 848) ||
942 (width
== 854 && height
== 480) ||
943 (width
== 480 && height
== 854))
945 layoutName
.Append(_L("WVGA "));
947 else if ( (width
== 480 && height
== 320) ||
948 (width
== 320 && height
== 480) ||
949 (width
== 640 && height
== 240) ||
950 (width
== 240 && height
== 640))
952 layoutName
.Append(_L("HVGA "));
956 layoutName
.Append(_L("Unknown "));
957 layoutName
.AppendNum(height
);
958 layoutName
.Append(_L("x"));
959 layoutName
.AppendNum(width
);
963 layoutName
.Append(_L("Landscape"));
967 layoutName
.Append(_L("Portrait"));
971 layoutName
.Append(_L(" Mirrored"));
976 // -----------------------------------------------------------------------------
978 // -----------------------------------------------------------------------------
980 CEikAppUi
* CPixelMetricsMapperDocument::CreateAppUiL()
982 return( new ( ELeave
) CPixelMetricsMapperAppUi
);
985 // -----------------------------------------------------------------------------
987 // -----------------------------------------------------------------------------
989 void CPixelMetricsMapperDocument::ConstructL()
993 // -----------------------------------------------------------------------------
995 // -----------------------------------------------------------------------------
997 TUid
CPixelMetricsMapperApplication::AppDllUid() const
999 return KUidPMMapperApplication
;
1003 // -----------------------------------------------------------------------------
1005 // -----------------------------------------------------------------------------
1007 CApaDocument
* CPixelMetricsMapperApplication::CreateDocumentL()
1009 CPixelMetricsMapperDocument
* document
=
1010 new( ELeave
) CPixelMetricsMapperDocument( *this );
1011 CleanupStack::PushL( document
);
1012 document
->ConstructL();
1013 CleanupStack::Pop();
1017 // ========================== OTHER EXPORTED FUNCTIONS =========================
1018 // ---------------------------------------------------------
1019 // NewApplication implements
1021 // Creates an instance of application.
1023 // Returns: an instance of CVtUiApp
1024 // ---------------------------------------------------------
1026 LOCAL_C CApaApplication
* NewApplication()
1028 return new CPixelMetricsMapperApplication
;
1031 // ---------------------------------------------------------
1032 // E32Main implements
1034 // It is called when executable is started.
1036 // Returns: error code.
1037 // ---------------------------------------------------------
1039 GLDEF_C TInt
E32Main()
1041 return EikStart::RunApplication( NewApplication
);