📄 osmo4_appui.cpp
字号:
/* * GPAC - Multimedia Framework C SDK * * Copyright (c) ENST 2006-200X * Authors: Jean Le Feuvre * All rights reserved * * This file is part of GPAC / Symbian GUI player * * GPAC is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */// INCLUDE FILES#include <avkon.hrh>#include <eikmenup.h>#include <akntitle.h>#include <stringloader.h>#include <osmo4.rsg>#include <f32file.h>#include <s32file.h>#include <bacline.h>#include <eikbtgps.h>#include <aknquerydialog.h> #include "osmo4_AppUi.h"#include "osmo4_AppView.h"#include "playlist.h"#include <gpac/utf.h>#include <gpac/options.h>// ============================ MEMBER FUNCTIONS ===============================// -----------------------------------------------------------------------------// Cosmo4AppUi::ConstructL()// Symbian 2nd phase constructor can leave.// -----------------------------------------------------------------------------//void COsmo4AppUi::ConstructL(){ // Initialise app UI with standard value. BaseConstructL(CAknAppUi::EAknEnableSkin); /*Create display*/ iAppView = COsmo4AppView::NewL( ClientRect() ); AddToStackL(iAppView); /*create playlist*/ iPlaylist = CPlaylist::NewL( ClientRect(), iAppView->GetUser() ); iPlaylist->MakeVisible(EFalse); iAppView->MakeVisible(ETrue); view_mode = 0; m_title = NULL; //StatusPane ()->SwitchLayoutL ( R_AVKON_STATUS_PANE_LAYOUT_SMALL ); nb_keys = 0; CaptureKeys(1); CCommandLineArguments *args = CCommandLineArguments::NewL(); if (args->Count() > 1) { TPtrC url = args->Arg(1);#if defined(_UNICODE) char szURL[1024]; u16 szURLUTF16[1024]; size_t len; len = url.Size(); memcpy(szURLUTF16, url.Ptr(), sizeof(u8)*len); szURLUTF16[len/2] = 0; const u16 *sptr = szURLUTF16; len = gf_utf8_wcstombs(szURL, 512, &sptr); if (len != (size_t) -1) { szURL[len] = 0; iAppView->Connect((const char *)szURL); }#else iAppView->Connect((const char *)url.Ptr());#endif } delete args;}// -----------------------------------------------------------------------------// COsmo4AppUi::COsmo4AppUi()// C++ default constructor can NOT contain any code, that might leave.// -----------------------------------------------------------------------------//COsmo4AppUi::COsmo4AppUi() { // No implementation required }// -----------------------------------------------------------------------------// COsmo4AppUi::~COsmo4AppUi()// Destructor.// -----------------------------------------------------------------------------//COsmo4AppUi::~COsmo4AppUi(){ CaptureKeys(0); switch (view_mode) { case 0: if (iAppView) RemoveFromStack(iAppView); break; case 1: if (iPlaylist) RemoveFromStack(iPlaylist); break; } if (iAppView) delete iAppView; if (iPlaylist) delete iPlaylist; if (m_title) free(m_title); m_title = NULL;}void COsmo4AppUi::CaptureKey(TInt32 code, TInt32 scancode){ RWindowGroup iWG = CCoeEnv::Static()->RootWin(); if (nb_keys>=MAX_KEY_CAP) return; keys[nb_keys].key_cap = iWG.CaptureKey(code, 0, 0); keys[nb_keys].key_cap_ud = iWG.CaptureKeyUpAndDowns(scancode, 0, 0); nb_keys++;}/*possible meaning for key codes:EStdKeyYes -CallEStdKeyNo -EndEStdKeyApplication0 -Apps keyEStdKeyDevice0 -Left softkeyEStdKeyDevice1 -Right softkeyEStdKeyDevice2 -PowerEStdKeyDevice3 -Button pressEStdKeyDevice4 -Flip - OpenEStdKeyDevice5 -Flip - CloseEStdKeyDevice6 -Side keyEStdKeyDeviceD -Jog Dial forwardEStdKeyDeviceE -Jog Dial back*/void COsmo4AppUi::CaptureKeys(int do_capture){ if (do_capture) { CaptureKey(EKeyIncVolume, EStdKeyIncVolume); CaptureKey(EKeyDecVolume, EStdKeyDecVolume); } else { RWindowGroup iWG = CCoeEnv::Static()->RootWin(); for (int i=0; i<nb_keys; i++) { iWG.CancelCaptureKey(keys[i].key_cap); iWG.CancelCaptureKeyUpAndDowns(keys[i].key_cap_ud); } nb_keys = 0; }}void COsmo4AppUi::HandleForegroundEventL(TBool aForeground){ CaptureKeys(aForeground ? 1 : 0); CAknAppUi::HandleForegroundEventL(aForeground);}// -----------------------------------------------------------------------------// COsmo4AppUi::HandleCommandL()// Takes care of command handling.// -----------------------------------------------------------------------------//void COsmo4AppUi::HandleCommandL( TInt aCommand ){ GF_Err e; switch( aCommand ) { case EAknSoftkeyBack: if (view_mode==1) TogglePlaylist(); break; case EEikCmdExit: case EAknSoftkeyExit: iAppView->Shutdown(); Exit(); break; /*PLAYLIST commands*/ case EOsmo4PlayListAdd: iPlaylist->PlaylistAct(Osmo4PLAdd); break; case EOsmo4PlayListRem: iPlaylist->PlaylistAct(Osmo4PLRem); break; case EOsmo4PlayListMoveUp: iPlaylist->PlaylistAct(Osmo4PLMoveUp); break; case EOsmo4PlayListMoveDown: iPlaylist->PlaylistAct(Osmo4PLMoveDown); break; case EOsmo4PlayListClear: iPlaylist->PlaylistAct(Osmo4PLClear); break; case EOsmo4PlayListMode: iPlaylist->PlaylistAct(Osmo4PLToggleMode); break; case EOsmo4PlayListAllFiles: iPlaylist->PlaylistAct(Osmo4PLToggleAllFiles); break; /*FILE menu command*/ case EOsmo4PlayListView: TogglePlaylist(); break; case EOsmo4OpenURL: break; case EOsmo4Reload: gf_term_navigate_to(iAppView->m_term, NULL); break; case EOsmo4Fullscreen: break; case EOsmo4ViewMaxSize: { CEikStatusPane* statusPane = StatusPane(); if (statusPane->IsVisible()) statusPane->MakeVisible(EFalse); else statusPane->MakeVisible(ETrue); } break; case EOsmo4AROriginal: gf_term_set_option(iAppView->m_term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_KEEP); break; case EOsmo4ARFillScreen: gf_term_set_option(iAppView->m_term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_FILL_SCREEN); break; case EOsmo4AR4_3: gf_term_set_option(iAppView->m_term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_4_3); break; case EOsmo4AR16_9: gf_term_set_option(iAppView->m_term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_16_9); break; case EOsmo4NavReset: gf_term_set_option(iAppView->m_term, GF_OPT_NAVIGATION_TYPE, 0); break; case EOsmo4NavNone: gf_term_set_option(iAppView->m_term, GF_OPT_NAVIGATION, GF_NAVIGATE_NONE); break; case EOsmo4NavSlide: e = gf_term_set_option(iAppView->m_term, GF_OPT_NAVIGATION, GF_NAVIGATE_SLIDE); if (e) { GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("Cannot set navigation: %s", gf_error_to_string(e) )); } break; case EOsmo4NavWalk: gf_term_set_option(iAppView->m_term, GF_OPT_NAVIGATION, GF_NAVIGATE_WALK); break; case EOsmo4NavFly: gf_term_set_option(iAppView->m_term, GF_OPT_NAVIGATION, GF_NAVIGATE_FLY); break; case EOsmo4NavExamine: gf_term_set_option(iAppView->m_term, GF_OPT_NAVIGATION, GF_NAVIGATE_EXAMINE); break; case EOsmo4NavHeadlight: gf_term_set_option(iAppView->m_term, GF_OPT_HEADLIGHT, !gf_term_get_option(iAppView->m_term, GF_OPT_HEADLIGHT) ); break; case EOsmo4CollideNone:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -