void UISingleTextInputDialog::MoveWindow(int _iLeft, int _iTop, int _iWidth, int _iHeight)
{
    DebugPrintf(DLC_UISINGLETEXTINPUTDLG, "%s, %d, %s, %s START", __FILE__,  __LINE__, GetClassName(), __FUNCTION__);
    CDisplay* pDisplay = CDisplay::GetDisplay();
    if (pDisplay)
    {
        _iWidth = m_DEFAULT_WIDTH;
        _iHeight = m_DEFAULT_HEIGHT;
        _iLeft = (pDisplay->GetScreenWidth() - _iWidth) >> 1;
        _iTop = 200;
    }
    UIWindow::MoveWindow(_iLeft, _iTop, _iWidth, _iHeight);

    int iTop = m_DEFAULT_MARGIN;
    int iLeft = m_DEFAULT_MARGIN;
    int iWidth = m_iWidth - (m_DEFAULT_MARGIN << 1);
    m_txtPasswordHintLabel.MoveWindow (iLeft, iTop, iWidth, m_DEFAULT_ELEMHEIGHT);
    iTop += m_DEFAULT_ELEMHEIGHT + m_DEFAULT_ELEMSPACING;
    
    m_tbPassword.MoveWindow(iLeft, iTop, iWidth, m_DEFAULT_ELEMHEIGHT);
    iTop += (m_DEFAULT_ELEMHEIGHT + m_DEFAULT_ELEMSPACING);
    
    if(m_iDialogType == Type_Default)
    {
        const int iBtnWidth = (iWidth - m_DEFAULT_ELEMSPACING) >> 1;
        m_btnCancel.MoveWindow(iLeft, iTop, iBtnWidth, m_DEFAULT_ELEMHEIGHT);
        iLeft += iBtnWidth + m_DEFAULT_ELEMSPACING;

        m_btnOK.MoveWindow(iLeft, iTop, iBtnWidth, m_DEFAULT_ELEMHEIGHT);
    }
    else if(m_iDialogType == Type_AddLabel)
Exemplo n.º 2
0
void UIFootNoteDialog::MoveWindow(int left, int top, int width, int height)
{
    DebugPrintf(DLC_UIFOOTNOTEDIALOG, "%s:%d:%s  %s start", __FILE__, __LINE__, __FUNCTION__, GetClassName());
    CDisplay* pDisplay = CDisplay::GetDisplay();
    if (pDisplay)
    {
        left = (pDisplay->GetScreenWidth() - m_maxWidth) >> 1;
    }
    UIWindow::MoveWindow(left, top, m_maxWidth, height);
    m_bottomSizer->Show(m_totalPage > 1);

    Layout();
    DebugPrintf(DLC_UIFOOTNOTEDIALOG, "%s:%d:%s  %s end", __FILE__, __LINE__, __FUNCTION__, GetClassName());
}
Exemplo n.º 3
0
BOOL BookOpenManager::OpenBook()
{
    DebugPrintf(DLC_BOOKOPENMANAGER, "%s, %d, %s, %s START", __FILE__,  __LINE__, "BookOpenManager", __FUNCTION__);
	if(!m_pCurPage)
	{
		return FALSE;
	}
	CDKFileManager * pclsFileManager = CDKFileManager::GetFileManager();
	if(!pclsFileManager)
	{
		return FALSE;
	}
	pclsFileManager->ConvertDKPToDKX(GetBookPath());

	//CHourglass* pIns = CHourglass::GetInstance();
	//if(m_iHourglassLeft == 0 && m_iHourglassTop == 0)
	//{
	//	pIns = NULL;
	//}

	//if(pIns)
	//{
	//	pIns->Start(m_iHourglassLeft, m_iHourglassTop);
	//}

	CDisplay* display = CDisplay::GetDisplay();
	if(NULL == display)
	{
		return FALSE;
	}

	DkFileFormat Format = GetBookFormat();
	switch (Format)
	{
	case DFF_Text:
		SQM::GetInstance()->IncCounter(SQM_ACTION_BOOKREADER_FORMAT_TXT);
		break;
	case DFF_ZipFile:
		SQM::GetInstance()->IncCounter(SQM_ACTION_BOOKREADER_FORMAT_ZIP);
		break;
	case DFF_RoshalArchive:
		SQM::GetInstance()->IncCounter(SQM_ACTION_BOOKREADER_FORMAT_RAR);
		break;
	case DFF_PortableDocumentFormat:
		SQM::GetInstance()->IncCounter(SQM_ACTION_BOOKREADER_FORMAT_PDF);
		break;            
	case DFF_ElectronicPublishing:
		SQM::GetInstance()->IncCounter(SQM_ACTION_BOOKREADER_FORMAT_EPUB);
		break;            
	case DFF_Serialized:
		SQM::GetInstance()->IncCounter(SQM_ACTION_BOOKREADER_FORMAT_SERIALIZED);
		break;         
	case DFF_Unknown:
		SQM::GetInstance()->IncCounter(SQM_ACTION_BOOKREADER_FORMAT_UNKNOWN);
		break;
	default:
		//DONOTHING for others
		break;
	}

	if(Format == DFF_ZipFile || Format == DFF_RoshalArchive || Format == DFF_Serialized)
	{

		BOOL bOpenSuccess = OpenArchiveBook();

		//if(pIns)
		//{
		//	pIns->Stop();
		//}

		return bOpenSuccess;
	}
	else
	{
		DkReaderPage *pReader = new DkReaderPage();
		if(NULL == pReader)
		{
			//if(pIns)
			//{
			//	pIns->Stop();
			//}

			return FALSE;
		}

		if (!pReader->Initialize(GetBookPath(), GetBookName(), m_iBookID))
		{
			delete pReader;
			pReader = NULL;
			//if(pIns)
			//{
			//	pIns->Stop();
			//}

			UIMessageBox messagebox(m_pCurPage, StringManager::GetStringById(CANNOT_OPEN_BOOK), MB_OK);
			messagebox.DoModal();
		}
		else
		{
			pReader->MoveWindow(0, 0, display->GetScreenWidth(), display->GetScreenHeight());
			//Here: we move the pIns->Stop() into UIBookReaderContainer::Draw() to fix bug like: KTV00026614
            CDisplay::GetDisplay()->SetFullRepaint(true);
			CPageNavigator::Goto(pReader);
		}
    }
    DebugPrintf(DLC_BOOKOPENMANAGER, "%s, %d, %s, %s end", __FILE__,  __LINE__, "BookOpenManager", __FUNCTION__);
	return TRUE;
}
Exemplo n.º 4
0
BOOL BookOpenManager::OpenArchiveBook()
{
    DebugPrintf(DLC_BOOKOPENMANAGER, "%s, %d, %s, %s START", __FILE__,  __LINE__, "BookOpenManager", __FUNCTION__);
	if(!m_pCurPage)
	{
		return FALSE;
	}

	CDisplay* display = CDisplay::GetDisplay();
	if(NULL == display)
	{
		return FALSE;
	}

	IFileContentsModel *pCurBookContent = NULL;
	if(S_FALSE == CFileContentsFactory::CreateFileContentsInstance(GetBookPath(),&pCurBookContent))
	{
		return FALSE;
	}

	if(NULL == pCurBookContent)
	{
		return FALSE;
	}

	char Password[128]={0};
	if(pCurBookContent->HasPassword())
	{
		if(GetFilePassword(m_pCurPage,m_iBookID,Password,128))
		{
			pCurBookContent->SetPassword(Password);
		}
		else
		{
			return TRUE;
		}
	}

	vector < CFileChapterInfo > ChapterList;
	if(!pCurBookContent->GetChapterList(ChapterList))
	{
		delete pCurBookContent;
		pCurBookContent = NULL;
		return FALSE;
	}

	int iChapterCount = ChapterList.size();
	FileListItem *pZipFileList = new FileListItem[iChapterCount];
	if(NULL == pZipFileList)
	{
		delete pCurBookContent;
		pCurBookContent = NULL;
		return FALSE;
	}

	INT iImageCount = 0;
	INT iAdjustIndex = 0;
	LPCSTR pExtension = NULL;
	LPCSTR pFileName = NULL;

	LPCSTR *pNameArray = new LPCSTR[iChapterCount];
	if(NULL == pNameArray)
	{
		delete pCurBookContent;
		pCurBookContent = NULL;

		delete[] pZipFileList;
		pZipFileList = NULL;
		return FALSE;
	}

	for(INT index= 0; index < iChapterCount; index++)
	{
		pExtension = ChapterList[index].GetChapterExName();
		if(DFC_Picture == GetFileCategoryForZipFile(pExtension))
		{
			pFileName = ChapterList[index].GetChapterPath();
			iAdjustIndex = AdjustFileList(pZipFileList, iImageCount, pNameArray, pFileName);

			pZipFileList[iAdjustIndex].uFileId = ChapterList[index].GetChapterId();
			pZipFileList[iAdjustIndex].eFileCategory = DFC_Picture;

			strncpy(pZipFileList[iAdjustIndex].pExtension, pExtension, 16);
			iAdjustIndex++;
			iImageCount++;
		}
	}

	DebugPrintf(DLC_BOOKOPENMANAGER, "BookOpenManager::OpenBook iImageCount %d\n", iImageCount);

	delete[] pNameArray;
	pNameArray = NULL;

	if(iChapterCount == iImageCount)
	{
		BookFileList * pZipBookList = new BookFileList();
		if(NULL == pZipBookList)
		{
			delete pCurBookContent;
			pCurBookContent = NULL;

			delete[] pZipFileList;
			pZipFileList = NULL;
			return FALSE;
		}

		pZipBookList->pFileList = pZipFileList;
		pZipBookList->iBookId= m_iBookID;
		pZipBookList->uLength = iImageCount;

		DkReaderPage *pReader = new DkReaderPage();
		if(NULL == pReader)
		{
			delete pCurBookContent;
			pCurBookContent = NULL;

			delete pZipBookList;
			pZipBookList = NULL;

			return FALSE;
		}

		if(!pReader->Initialize(SPtr<BookFileList>(pZipBookList), 0, TRUE,Password))
		{

			UIMessageBox messagebox(m_pCurPage, StringManager::GetStringById(CANNOT_OPEN_BOOK), MB_OK);
			messagebox.DoModal();

			delete pCurBookContent;
			pCurBookContent = NULL;

			delete pReader;
			pReader = NULL;
			return FALSE;
		}
		else
		{
			pReader->MoveWindow(0, 0, display->GetScreenWidth(), display->GetScreenHeight());
			CPageNavigator::Goto(pReader);
			delete pCurBookContent;
			pCurBookContent = NULL;
			return TRUE;
		}
	}
	else	//如果压缩包中含有非图片内容,则暂不支持!
    {
        UIMessageBox messagebox(m_pCurPage, StringManager::GetStringById(CANNOT_OPEN_BOOK), MB_OK);
        messagebox.DoModal();

		delete pCurBookContent;
		pCurBookContent = NULL;
		delete[] pZipFileList;
		pZipFileList = NULL;
		return FALSE;
    }
    DebugPrintf(DLC_BOOKOPENMANAGER, "%s, %d, %s, %s end", __FILE__,  __LINE__, "BookOpenManager", __FUNCTION__);
    return true;
}
Exemplo n.º 5
0
void UIDownloadPage::OnWifiMessage(SNativeMessage event)
{
	if(!m_bIsVisible)
	{
		return;
	}

	if(ALLRECEIVER != event.iParam1)
	{
		LPSTR pReceiver = (LPSTR)event.iParam1;

		if(!pReceiver || strcmp(this->GetClassName(),pReceiver) != 0)
		{
			return;
		}
	}

	switch(event.iParam2)
	{
	case UPDATE_WIFI_STATUS:

		{
			UpdateTitleBar();
		}
		break;

	case POWERONOFF_WIFI:
		{
			UpdateTitleBar();
			WifiManager* wifiManager = WifiManager::GetInstance();
			if(wifiManager && wifiManager->IsPowerOn())
			{
				if(!wifiManager->IsConnected())
				{
					DebugPrintf(DLC_LIUJT, "UIDownloadPage::OnWifiMessage  No wifi connected, begin to auto join!");
					wifiManager->StartAutoJoin(WifiStatusCallBack, ConnectWifiCallBack);
				}
				else
				{
					DebugPrintf(DLC_LIUJT, "UIDownloadPage::OnWifiMessage  Has one wifi connected!!!");
				}
			}
			else
			{
				DebugPrintf(DLC_LIUJT, "UIDownloadPage::OnWifiMessage  Has no power now!!!");
			}
		}
		break;

	case CONNECT_WIFI:
		{
			UpdateTitleBar();
			ConnectionMessage* cm = (ConnectionMessage*)event.iParam3;
			if(cm && !cm->GetWifiConnected())
			{
				delete cm;
				cm = NULL;

				UIWifiDialog m_WifiDialog(this);
				CDisplay* pDisplay = CDisplay::GetDisplay();
				if(pDisplay)
				{
					m_WifiDialog.MoveWindow(0,0,pDisplay->GetScreenWidth(), pDisplay->GetScreenHeight());
					m_WifiDialog.DoModal();
				}
			}
		}

		break;
	default:
		break;

	}
}