Esempio n. 1
0
bool AP_Win32LeftRuler::registerClass(XAP_Win32App * app)
{
	ATOM a;
	UT_Win32LocaleString str;
 	
	str.fromASCII (app->getApplicationName());
	// register class for the left ruler
	swprintf(s_LeftRulerWndClassName, L"%sLeftRuler",  str.c_str());

	a = UT_RegisterClassEx(CS_DBLCLKS | CS_OWNDC, AP_Win32LeftRuler::_LeftRulerWndProc, app->getInstance(),
						   NULL, LoadCursor(NULL, IDC_ARROW), GetSysColorBrush(COLOR_BTNFACE), NULL,
						   NULL, s_LeftRulerWndClassName);
	
	UT_ASSERT_HARMLESS(a);

	return true;
}
BOOL AP_Win32Dialog_New::_onInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
	m_hThisDlg = hWnd;

	XAP_Win32App * app = static_cast<XAP_Win32App *> (m_pApp);
	UT_return_val_if_fail (app,1);

	const XAP_StringSet * pSS = m_pApp->getStringSet();

	_win32Dialog.setDialogTitle(pSS->getValue(AP_STRING_ID_DLG_NEW_Title));

	// localize controls
	_DSX(NEW_BTN_OK,		DLG_OK);
	_DSX(NEW_BTN_CANCEL,	DLG_Cancel);
	_DS(NEW_RDO_TEMPLATE,	DLG_NEW_Create);
	_DS(NEW_RDO_EXISTING,	DLG_NEW_Open);
    _DS(NEW_BTN_EXISTING,	DLG_NEW_Choose);

	// set initial state
	_win32Dialog.setControlText(AP_RID_DIALOG_NEW_EBX_EXISTING, 
  								pSS->getValue(AP_STRING_ID_DLG_NEW_NoFile));

	HWND hControl = GetDlgItem(hWnd, AP_RID_DIALOG_NEW_LBX_TEMPLATE);

	long findtag;
	struct _finddata_t cfile;
	UT_String templateName, searchDir;
	templateName = XAP_App::getApp()->getUserPrivateDirectory(); 
	searchDir = XAP_App::getApp()->getUserPrivateDirectory();
	searchDir += "\\templates\\*.awt";
	findtag = _findfirst( searchDir.c_str(), &cfile );
	if( findtag != -1 )
	{
		do
		{	
			templateName = XAP_App::getApp()->getUserPrivateDirectory();
			templateName += "\\templates\\";
			templateName += cfile.name;
			if(!strstr(templateName.c_str(), "normal.awt-")) // don't truncate localized template names
				templateName = templateName.substr ( 0, templateName.size () - 4 ) ;

			UT_Win32LocaleString str;
			str.fromASCII (templateName.c_str());
			char *uri = UT_go_filename_to_uri(str.utf8_str().utf8_str());
			UT_continue_if_fail(uri);

			UT_sint32 nIndex = SendMessageW( hControl, LB_ADDSTRING, 0, (LPARAM) UT_basename( uri ) );
			SendMessageW( hControl, LB_SETITEMDATA, (WPARAM) nIndex, (LPARAM) 0 );

			g_free(uri);
		} while( _findnext( findtag, &cfile ) == 0 );
	}
	_findclose( findtag );

	templateName = XAP_App::getApp()->getAbiSuiteLibDir(); 
	searchDir = XAP_App::getApp()->getAbiSuiteLibDir();
	searchDir += "\\templates\\*.awt";
	findtag = _findfirst( searchDir.c_str(), &cfile );
	if( findtag != -1 )
	{
		do
		{	
			templateName = XAP_App::getApp()->getAbiSuiteLibDir();
			templateName += "\\templates\\";
			templateName += cfile.name;
			if(!strstr(templateName.c_str(), "normal.awt-"))  // don't truncate localized template names
				templateName = templateName.substr ( 0, templateName.size () - 4 ) ;

            UT_Win32LocaleString str;
			str.fromASCII (templateName.c_str());
			char *uri = UT_go_filename_to_uri(str.utf8_str().utf8_str());
			UT_continue_if_fail(uri);

			UT_sint32 nIndex = SendMessageW( hControl, LB_ADDSTRING, 0, (LPARAM) UT_basename( uri ) );
			SendMessageW( hControl, LB_SETITEMDATA, (WPARAM) nIndex, (LPARAM) 1 );

			g_free(uri);
		} while( _findnext( findtag, &cfile ) == 0 );
	}
	_findclose( findtag );

	XAP_Win32DialogHelper::s_centerDialog(hWnd);	
	_updateControls();
	return 1;	// 1 == we did not call SetFocus()
}
BOOL AP_Win32Dialog_ListRevisions::_onInitDialog(HWND hWnd, WPARAM /*wParam*/, LPARAM /*lParam*/)
{
	const XAP_StringSet * pSS = m_pApp->getStringSet();
    
	setDialogTitle (getTitle());

	// localize controls
	_DSX(BTN_OK,			DLG_OK);
	_DSX(BTN_CANCEL,		DLG_Cancel);

	setDlgItemText(AP_RID_DIALOG_LIST_REVISIONS_FRAME,getLabel1());

	// set the column headings
	HWND h = GetDlgItem(hWnd, AP_RID_DIALOG_LIST_REVISIONS_LIST);

    LVCOLUMNW col;
    UT_Win32LocaleString str;
	col.mask = LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH;

	int col_hdr[3]={AP_STRING_ID_DLG_ListRevisions_Column1Label,
					AP_STRING_ID_DLG_ListRevisions_Column2Label,
					AP_STRING_ID_DLG_ListRevisions_Column3Label};
	int col_wid[3]={80,160,230};

	for (int i=0; i<3; i++) {
		col.iSubItem = i;
		col.cx = col_wid[i];
		str.fromUTF8(pSS->getValue(col_hdr[i]));
		col.pszText = (LPWSTR) str.c_str();
		SendMessageW(h, LVM_INSERTCOLUMNW, i, (LPARAM)&col);
	}

	ListView_SetItemCount(h, getItemCount());

	LVITEMW item;
	item.state = 0;
	item.stateMask = 0;
	item.iImage = 0;

	WCHAR buf[60];
	const char *tmp;
	item.pszText = buf;

	for(UT_uint32 i = 0; i < getItemCount(); i++)
	{
		wsprintfW(buf,L"%d",getNthItemId(i));
		item.pszText = buf;
		item.iItem = i;
		item.iSubItem = 0;
		item.lParam = getNthItemId(i);
		item.mask = LVIF_TEXT | LVIF_PARAM;
		SendMessageW(h, LVM_INSERTITEMW, 0, (LPARAM)&item);

		item.iSubItem = 1;
		tmp=getNthItemTime(i);
		if (tmp) {
			str.fromASCII(tmp,-1);
			item.pszText = (LPWSTR) str.c_str();
		} else {
			item.pszText = L"";
		}
		item.mask = LVIF_TEXT;
		SendMessageW(h, LVM_SETITEMW, 0, (LPARAM)&item);
		
		item.iSubItem = 2;
		str.fromUTF8(getNthItemText(i));
		item.pszText = (LPWSTR) str.c_str();
		item.mask = LVIF_TEXT;
		SendMessageW(h, LVM_SETITEMW, 0, (LPARAM)&item);
	}
   
	SendMessageW(h, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT);  								
    centerDialog();	

	return 1;							// 1 == we did not call SetFocus()
}