触摸界面的全屏模式
文章信息
Contents |
概述
S60手机第五版触摸屏没有硬件CBA按钮,因此如果我们需要一个全屏模式我们不需要隐藏control pane否则用户无法访问菜单。
要计算实际全屏的尺寸(如考虑到control pane的区域)我们将需要使用AknLayoutUtils来帮助我们。
MMP文件
LIBRARY avkon.lib
LIBRARY eikcore.lib
CAPABILITY could be self-signed
Header file
class CAknViewClass: public CAknView ...
{
...
public:
void ConstructL();
void SetFullRect();
private:
void CalculateFullscreenRect();
private:
TRect iFullRect;
...
};
class CAknAppUiClass: public CAknAppUi
{
...
protected:
void HandleResourceChangeL( TInt aType );
private:
CAknViewClass* iViewInstance;
...
};
源文件
#include <AknUtils.h>
...
void CAknViewClass::ConstructL()
{
...
// Calculate actual full-screen mode rect
CalculateFullscreenRect();
// Set view extent
SetRect(iFullRect);
...
}
void CAknViewClass:SetFullRect()
{
SetRect(iFullRect);
}
...
void CAknViewClass::CalculateFullscreenRect()
{
// Window that fills the entire screen
TRect temp_rect;
AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EApplicationWindow, temp_rect);
iFullRect = temp_rect;
// Rect that occupied by control pane (i.e. CBA)
AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EControlPane, temp_rect);
// Calculate final rect which depends on CBA location
AknLayoutUtils::TAknCbaLocation cba_location = AknLayoutUtils::CbaLocation();
switch(cba_location) {
case AknLayoutUtils::EAknCbaLocationBottom:
iFullRect.iBr.iY -= temp_rect.Height();
break;
case AknLayoutUtils::EAknCbaLocationLeft:
iFullRect.iTl.iX += temp_rect.Width();
break;
case AknLayoutUtils::EAknCbaLocationRight:
iFullRect.iBr.iX -= temp_rect.Width();
break;
default:
break;
}
}
CAknAppUiClass::HandleResourceChangeL( TInt aType )
{
...
iViewInstance->CalculateFullscreenRect();
iViewInstance->SetFullRect();
...
}
后记
触摸屏将可以支持全屏模式。


(no comments yet)