裝置, 軟體 版本:
S60 3rd Edition
S60 3rd Edition, FP1
詳細描述:
預設情況下,程式是根據手機螢幕的當前方向開始啟動的。如果要強製程序以橫屏或豎屏的模式啟動,那我們在CAknAppUi::ConstructL()方法中調用BaseConstructL()時就要傳遞相應的flag值:
void CMyAppUi::ConstructL()
{
BaseConstructL( EAknEnableSkin | EAppOrientationLandscape ); // start in landscape mode
...
}
如果要在程式運行期間改變方向,則需要調用:
void CAknAppUiBase::SetOrientationL( TAppUiOrientation aOrientation );
這裡的參數為EAppUiOrientationLandscape和EAppUiOrientationPortrait,注意這種情況下的調用就不要再向BaseConstructL()中傳遞相同的參數了。
注意
- 橫屏(landscape),前者是橫幅,一般多用在風景照,所以叫"landscape"。
- 豎屏(portrait),後者是直幅,一般多用在肖像上,所以叫"portrait"。
symbian 介面繪製收藏
全屏
構造container時,將AppUi()->ApplicationRect()做為參數aRect傳遞進去。
然後在container建構函式中調用SetRect(aRect);這樣即可全螢幕顯示
隱藏狀態列
CEikStatusPane* statusPane = StatusPane();
statusPane->MakeVisible( EFalse );
旋轉螢幕
2.8,3.0 SDK支援旋轉螢幕,程式裡面可以捕獲該訊息,然而使UI自訂的改變位置
繼承的函數為:Container::HandleResourceChange,原先的SizeChange這個函數不會響應
在該函數內不要使用AppUi->ClientRect函數來擷取工作區範圍,資料會有偏差(這個問題鬱悶了好久),可以使用
TRect rect;
AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane,rect );
來擷取RECT
全屏到正常
User "SetRect" inside your container. Pass in the original client area rect parameter back to the CCoeControl.
You may use the following code:
1) Before calling "SetExtentToWholeScreen", save the rect:
iRect = Rect();
Gets the control's extent
2) call "SetExtentToWholeScreen"
3) Switch back:
SetRect( iRect );
擷取當前旋轉狀態
http://wiki.forum.nokia.com/index.php/How_to_get_the_Current_Orientation
#include <aknappui.h>
CCoeEnv* env = CCoeEnv::Static();
if( env )
{
CAknAppUiBase* appUiBase = REINTERPRET_CAST( CAknAppUiBase*, env->AppUi() );
if( appUiBase )
{
/*
* Possible values for TAppUiOrientation are :
* EAppUiOrientationUnspecified,
* EAppUiOrientationPortrait,
* EAppUiOrientationLandscape,
* EAppUiOrientationAutomatic
**/
CAknAppUiBase::TAppUiOrientation orientation = appUiBase->Orientation();
}
}