Exemplo n.º 1
0
void CAlertDialog::DoInitTemplate() 
{
#ifdef OS_WINCE
	int initialWidth  = GetSystemMetrics(SM_CXSCREEN)/3;
#else 
	int initialWidth  = CMainWindow::getScreenWidth()/3;
#endif
	int initialHeight = initialWidth/3;

	m_Template.Create(false, convertToStringW(m_title).c_str(), 
						0, 
						0,
						initialWidth, 
						initialHeight,
						CAlertDialogTraits::GetWndStyle(0), 
						CAlertDialogTraits::GetWndExStyle(0));
}
Exemplo n.º 2
0
void DrawingContextImpl::drawText(int x, int y,  int nWidth, int nHeight, String const &text, int color) {
	RHO_MAP_TRACE2("DrawingContext drawText with x = %d, y = %d", x, y);

	HFONT hfontTahoma;         
	LOGFONT logfont;          
	HFONT hfontSave = NULL;
  
    memset (&logfont, 0, sizeof (logfont));
	logfont.lfHeight = 18;
	logfont.lfWidth = 0;
	logfont.lfEscapement = 0;
	logfont.lfOrientation = 0;
	logfont.lfWeight = FW_BOLD;
	logfont.lfItalic = FALSE;
	logfont.lfUnderline = FALSE;
	logfont.lfStrikeOut = FALSE;
	logfont.lfCharSet = DEFAULT_CHARSET;
	logfont.lfOutPrecision = OUT_DEFAULT_PRECIS;
	logfont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
	logfont.lfQuality = DEFAULT_QUALITY;
	logfont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
	_tcsncpy (logfont.lfFaceName, TEXT("Tahoma"), LF_FACESIZE);
	logfont.lfFaceName[LF_FACESIZE-1] = TEXT('\0');  // Ensure null termination
	hfontTahoma = CreateFontIndirect (&logfont);

	if (hfontTahoma) {
		hfontSave = (HFONT) SelectObject(mHDC, hfontTahoma);
	}

	StringW pathW = convertToStringW(text);
	SetBkMode(mHDC, TRANSPARENT);
	SetTextColor(mHDC, color & 0xFFFFFF);
	//TextOut(mHDC, x, y, pathW.c_str(), pathW.length());
	RECT r;
	r.left = x;
	r.top = y;
	r.right = x+nWidth;
	r.bottom = y + nHeight;
	DrawText(mHDC, pathW.c_str(), -1, &r, DT_LEFT | DT_TOP);

	if (hfontTahoma) {
		SelectObject(mHDC, hfontSave);
		DeleteObject (hfontTahoma);
	}
}
Exemplo n.º 3
0
LRESULT CTimePickerDialog::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
	if ((m_title != NULL) && (strlen(m_title) > 0)) {
		String title = m_title;
		StringW title_w = convertToStringW(title);
		//SetWindowText(title_w.c_str());
		//GetDlgItem(IDC_TIME_CTRL).SetWindowText(title_w.c_str());
		SetDlgItemText(ID_TIME_CAPTION, title_w.c_str());
	}
	else {
		SetWindowText(_T("Date"));
	}

#if defined(_WIN32_WCE)

    SHINITDLGINFO shidi = { SHIDIM_FLAGS, m_hWnd, SHIDIF_SIZEDLGFULLSCREEN };
    RHO_ASSERT(SHInitDialog(&shidi));

    SHMENUBARINFO mbi = { sizeof(mbi), 0 };
    mbi.hwndParent = m_hWnd;
    mbi.nToolBarId = IDR_GETURL_MENUBAR;
    mbi.hInstRes = _AtlBaseModule.GetResourceInstance();
    RHO_ASSERT(SHCreateMenuBar(&mbi));
	GotoDlgCtrl(GetDlgItem(IDC_TIME_CTRL));

	SYSTEMTIME start_time;
	if (m_initialTime != 0) {
		UnixTimeToSystemTime(m_initialTime, &start_time);
		DateTime_SetSystemtime( GetDlgItem(IDC_TIME_CTRL), GDT_VALID, &start_time);
	}

#else

	CreateButtons();
	GotoDlgCtrl(m_btnOk);

#endif

	DLG_ITEM_SET_FONT_BOLD (IDC_TIME_STATIC);
	DLG_ITEM_SET_FONT_BOLD (ID_TIME_CAPTION);

    return FALSE;
}
Exemplo n.º 4
0
void CRingtoneManager::play (String ringtone_name)
{
    HRESULT hr;
    
    stop();
    
    StringW ringtone_nameW = convertToStringW(ringtone_name);

    hr = SndOpen( ringtone_nameW.c_str(), &m_hSound);
    if (hr != S_OK || !m_hSound) {
        //TODO: log extended error
        LOG(ERROR) + "RingtoneManager: failed to open file";
        return;
    }
    hr = SndPlayAsync (m_hSound, 0);
    if (hr != S_OK) {
        //TODO: log extended error
        LOG(ERROR) + "RingtoneManager: failed to play file";
        return;
    }
}
Exemplo n.º 5
0
/*static*/ unsigned int CRhoFile::deleteFolder(const char* szFolderPath) 
{
#if !defined(OS_WP8)
#if defined(WINDOWS_PLATFORM)

	StringW  swPath;
    convertToStringW(szFolderPath, swPath);
	wchar_t* name = new wchar_t[ swPath.length() + 2];
    swprintf(name, L"%s%c", swPath.c_str(), '\0');
    translate_wchar(name, L'/', L'\\');

    SHFILEOPSTRUCTW fop = {0};

	fop.hwnd = NULL;
	fop.wFunc = FO_DELETE;		
        fop.pFrom = name;
	fop.pTo = NULL;
	fop.fFlags = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR 
#if defined(OS_WINDOWS_DESKTOP) || defined(OS_PLATFORM_MOTCE)
                 | FOF_NOERRORUI
#endif        
        ;
        int result = SHFileOperationW(&fop);

    delete name;

    return result == 0 ? 0 : (unsigned int)-1;
#elif defined (OS_ANDROID)

    return iterateFolderTree(String(szFolderPath), RemoveFileFunctor(szFolderPath));

#else
    rho_file_impl_delete_folder(szFolderPath);
    return 0;
#endif
#else
	return 0;
#endif
}
Exemplo n.º 6
0
StringW CExtManager::getCurrentUrl()
{
    return convertToStringW(RHODESAPP().getCurrentUrl(rho_webview_active_tab()));
}
Exemplo n.º 7
0
LRESULT CAlertDialog::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL&bHandled)
{

#define MAX(i, j)   ((i) > (j) ? (i) : (j))
#define MIN(i, j)   ((i) < (j) ? (i) : (j))

	const int GAP    = 12; //space around dialog
	const int INDENT = 14;  //for dialog items

#ifdef OS_WINCE
	unsigned int maxWidth  = GetSystemMetrics(SM_CXSCREEN) - (GAP * 2);
	unsigned int maxHeight = GetSystemMetrics(SM_CYSCREEN) - (GAP * 2);
#else
	int maxWidth  = CMainWindow::getScreenWidth() - (GAP * 2);
	int maxHeight = CMainWindow::getScreenHeight() - (GAP * 2);
#endif
	int xBorderWidth = GetSystemMetrics(SM_CXEDGE);
	int yBorderWidth = GetSystemMetrics(SM_CYEDGE);
	CClientDC dc(m_hWnd);
	TEXTMETRIC tm = { 0 };
	RECT rect = {0}, dlgRect, iconRect = {0 }, msgRect = { 0 }, buttonsRect = { 0 };

	GetClientRect(&dlgRect);

	/***************************************************************************
      Icon.
	 ***************************************************************************/
	HICON hIcon = loadIcon();
	if (hIcon == NULL) {
		LOG(ERROR) + "Failed to load icon";
	} else {
		iconRect.left = INDENT;
		iconRect.top  = INDENT;
		iconRect.right  = iconRect.left + GetSystemMetrics(SM_CXICON);
		iconRect.bottom = iconRect.top + GetSystemMetrics(SM_CYICON);

		m_iconCtrl.Create(m_hWnd, iconRect, NULL, WS_CHILD | WS_VISIBLE | SS_ICON);
		m_iconCtrl.SetIcon(hIcon);
	}
	int iconHeight = iconRect.bottom - iconRect.top;
	int iconWidth  = iconRect.left - iconRect.right;

	/***************************************************************************
	  Message.
	 ***************************************************************************/
	GetClientRect(&dlgRect);

	//create control
	m_messageCtrl.Create(m_hWnd, CWindow::rcDefault, NULL, WS_CHILD | WS_VISIBLE);

	//change control  font to normal
	HFONT hFont = m_messageCtrl.GetFont();
	LOGFONT fontAttributes = { 0 };
    ::GetObject(hFont, sizeof(fontAttributes), &fontAttributes);
    fontAttributes.lfWeight = FW_NORMAL;
	hFont = CreateFontIndirect(&fontAttributes);
	m_messageCtrl.SetFont(hFont);


	//get text metrics
	dc.GetTextMetrics(&tm);

	int msgWidth  =  (int)(m_message.length() * (tm.tmAveCharWidth * 1.3) + (2 * INDENT));
	int msgHeight =  tm.tmHeight + tm.tmExternalLeading + tm.tmInternalLeading;

	int desiredDlgWidth = iconRect.right + msgWidth + (INDENT * 2);

	//space around label on buttons.
	const int btnHIndent = 12; //horizontal
	const int btnVIndent = 8;  //vertical

	int btnsNum = m_buttons.size(); 
	int btnsHeight =tm.tmHeight + btnVIndent;

	//if desired widht is bigger than current - make dialog window bigger
	if (desiredDlgWidth > (dlgRect.right - dlgRect.left)) {
		// if desired width is bigger than maximum width 
		// - recalculate dialog window with wrapped text 
		if (desiredDlgWidth >= (int)maxWidth) {
			msgWidth = maxWidth - (iconRect.right + INDENT*2 + xBorderWidth*2);
			msgHeight = (((m_message.length() * tm.tmAveCharWidth) / msgWidth) + 1) 
						* (tm.tmHeight + tm.tmExternalLeading + tm.tmInternalLeading);
			desiredDlgWidth = maxWidth;
		}
		
		MoveWindow(0, 0, desiredDlgWidth,
					MAX(iconRect.bottom, msgHeight) + GetSystemMetrics(SM_CYCAPTION) + INDENT + yBorderWidth * 2 +
                    btnsHeight);
	} else {
		//TODO: centering message
	}
	
	m_messageCtrl.SetWindowText(convertToStringW(m_message).c_str());
	
	//LOG(INFO) + "iconHeight  msgHeight " + iconHeight + " "+ msgHeight;

	if (iconHeight > msgHeight) {
		msgRect.left = iconRect.right + INDENT;
		msgRect.top  = iconRect.top + (iconHeight - msgHeight)/2;
		msgRect.right  = msgRect.left + msgWidth;
		msgRect.bottom = msgRect.top + msgHeight;
		//center message on icon
		m_messageCtrl.MoveWindow(iconRect.right + INDENT, iconRect.top + (iconHeight - msgHeight)/2, msgWidth, msgHeight);
	} else {
		msgRect.left = iconRect.right + INDENT;
		msgRect.top  = iconRect.top;
		msgRect.right  = msgRect.left + msgWidth;
		msgRect.bottom = msgRect.top + msgHeight;
		m_messageCtrl.MoveWindow(iconRect.right + INDENT, iconRect.top, msgWidth, msgHeight);
		//center icon on message
		if (hIcon) {
			m_iconCtrl.MoveWindow(INDENT, iconRect.top + (msgHeight - iconHeight)/2, iconWidth, iconHeight);
			m_iconCtrl.SetIcon(hIcon);
		}
	}

	//for Wait dailog text should be centered
	if (m_buttons.size() == 0) {
		m_messageCtrl.CenterWindow();
	}
	
	/***************************************************************************
	  Buttons.
	 ***************************************************************************/

	GetClientRect(&dlgRect);

	//for (Vector<CustomButton>::iterator itr = m_buttons.begin(); itr != m_buttons.end(); ++itr) {
	//	btnsWidth += (itr->m_title.length() * tm.tmAveCharWidth) + btnHIndent + (INDENT * 2);
	//}

	POINT point;
	point.x = INDENT, point.y = (iconHeight > msgHeight ? point.y = iconHeight + 6 : msgHeight + 2) + INDENT;

	unsigned int btnWidth = 87, btnHeight = 0;
	btnHeight = tm.tmHeight + btnVIndent;

	//if (iconHeight + msgHeight + INDENT + btnHeight + INDENT > dlgRect.) {
	//}

	for (Vector<CustomButton>::iterator itr = m_buttons.begin(); itr != m_buttons.end(); ++itr) 
    {
		//btnWidth = (itr->m_title.length() * tm.tmAveCharWidth) + btnHIndent;

		RECT rc = {point.x, point.y, point.x + btnWidth, point.y + btnHeight};
		itr->Create(m_hWnd, rc, 
					convertToStringW(itr->m_title).c_str(),
					WS_CHILD | WS_VISIBLE, 0, 
					itr->m_numId);

		point.x += btnWidth + INDENT;
	}

	CenterWindow();

	return bHandled = FALSE;

#undef MAX
#undef MIN
}
Exemplo n.º 8
0
HRESULT Camera::selectPicture(HWND hwndOwner,LPTSTR pszFilename) 
{
	RHO_ASSERT(pszFilename);
#if defined( _WIN32_WCE ) //&& !defined( OS_PLATFORM_MOTCE )
	OPENFILENAMEEX ofnex = {0};
	OPENFILENAME ofn = {0};
#else
    OPENFILENAME ofn = {0};
#endif
    pszFilename[0] = 0;

	ofn.lStructSize     = sizeof(ofn);
    ofn.hwndOwner       = hwndOwner;
	ofn.lpstrFilter     = NULL;
	ofn.lpstrFile       = pszFilename;
	ofn.nMaxFile        = MAX_PATH;
	ofn.lpstrInitialDir = NULL;
	ofn.lpstrTitle      = _T("Select an image");
#if defined( _WIN32_WCE ) //&& !defined( OS_PLATFORM_MOTCE )
	BOOL bRes = false;
	if(RHO_IS_WMDEVICE)
	{
		ofnex.ExFlags = OFN_EXFLAG_THUMBNAILVIEW|OFN_EXFLAG_NOFILECREATE|OFN_EXFLAG_LOCKDIRECTORY;
		bRes = lpfn_GetOpen_FileEx(&ofnex);
	}
	else
		bRes = GetOpenFileName(&ofn);

    if (bRes)
#else
    if (GetOpenFileName(&ofn))
#endif

    {
		HRESULT hResult = S_OK;

        /*
		TCHAR rhoroot[MAX_PATH];
		wchar_t* root  = wce_mbtowc(rho_rhodesapp_getblobsdirpath());
		wsprintf(rhoroot,L"%s",root);
		free(root);

		create_folder(rhoroot);*/

        StringW strBlobRoot = convertToStringW( RHODESAPP().getBlobsDirPath() );

        LPCTSTR szExt = wcsrchr(pszFilename, '.');
		StringW strFileName = generate_filename(szExt);
		StringW strFullName = strBlobRoot + L"\\" + strFileName;

		if (copy_file( pszFilename, strFullName.c_str() )) 
        {
			wcscpy( pszFilename, strFileName.c_str() );
		} else {
			hResult = E_INVALIDARG;
		}

		return hResult;
	} else if (GetLastError()==ERROR_SUCCESS) {
		return S_FALSE; //user cancel op
	}
	return E_INVALIDARG;
}