本文整理汇总了C++中UT_Win32LocaleString::fromLocale方法的典型用法代码示例。如果您正苦于以下问题:C++ UT_Win32LocaleString::fromLocale方法的具体用法?C++ UT_Win32LocaleString::fromLocale怎么用?C++ UT_Win32LocaleString::fromLocale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UT_Win32LocaleString
的用法示例。
在下文中一共展示了UT_Win32LocaleString::fromLocale方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void XAP_Win32DialogBase::getComboTextItem(UT_sint32 controlId, int index, UT_Win32LocaleString& str)
{
UT_return_if_fail(IsWindow(m_hDlg));
wchar_t szBuff[1024];
if (SendDlgItemMessageW(m_hDlg, controlId, CB_GETLBTEXT, index, (LPARAM)szBuff) != CB_ERR)
str.fromLocale(szBuff);
else
str.clear();
}
示例2: GetDlgItemTextW
bool XAP_Win32DialogBase::getDlgItemText(int nIDDlgItem, UT_Win32LocaleString& str)
{
wchar_t szBuff [1024];
bool rslt;
rslt = (bool) GetDlgItemTextW(m_hDlg, nIDDlgItem, szBuff, 1024);
if (rslt == true)
str.fromLocale(szBuff);
else
str.clear();
return rslt;
}
示例3:
int CALLBACK AP_Win32Toolbar_FontCombo::_EnumFontsProc(LPLOGFONTW lplf,
LPTEXTMETRICW lptm,
DWORD dwStyle,
LONG lParam)
{
AP_Win32Toolbar_FontCombo * ctl = (AP_Win32Toolbar_FontCombo *) lParam;
UT_return_val_if_fail (ctl, 0);
/*
WARNING: any changes to this function should be closely coordinated
with the equivalent logic in Win32Graphics::FindFont()
*/
// filter out fonts we don't use
if (dwStyle & RASTER_FONTTYPE)
return 1 ;
#if 0
// This is too restrictive. Since EnumFontFamilies chooses at random
// the character set for the chosen font family, we were missing things
// here. Perhaps use EnumFontFamiliesEx instead?
if (lplf->lfCharSet != ANSI_CHARSET)
return 1 ;
#endif
// filter out vertical fonts which aren't supported
if (lplf->lfFaceName[0]=='@')
return 1;
UT_Win32LocaleString str;
str.fromLocale (lplf->lfFaceName);
char * p = g_strdup((str.utf8_str().utf8_str()));
if (seenFonts.find(p)!=seenFonts.end()) {
FREEP(p);
return 1;
}
ctl->m_vecContents.addItem(p);
ctl->m_vecFontCharSet.addItem((void*)lplf->lfCharSet);
seenFonts.insert(p);
return 1;
}
示例4: HIWORD
BOOL AP_Win32Dialog_MailMerge::_onCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
WORD wNotifyCode = HIWORD(wParam);
WORD wId = LOWORD(wParam);
HWND hWndCtrl = (HWND)lParam;
switch (wId)
{
case AP_RID_DIALOG_MAILMERGE_LISTBOX:
if (HIWORD(wParam)==LBN_DBLCLK)
{
UT_Win32LocaleString str;
int nItem = SendMessageW(GetDlgItem(m_hDlg, AP_RID_DIALOG_MAILMERGE_LISTBOX), LB_GETCURSEL, 0, 0);
if (nItem!=LB_ERR)
{
// get the mail merge field from the listbox
HWND lBox = GetDlgItem(m_hDlg, AP_RID_DIALOG_MAILMERGE_LISTBOX);
UT_sint32 len = SendMessageW(lBox, LB_GETTEXTLEN, nItem, (LPARAM)0);
wchar_t* szBuff = (wchar_t*)g_malloc(sizeof(wchar_t) * (len + 1));
SendMessageW(lBox, LB_GETTEXT, nItem, (LPARAM)szBuff);
str.fromLocale(szBuff);
FREEP(szBuff);
setMergeField(str.utf8_str());
addClicked();
}
return 1;
}
else
{
return 0;
}
case AP_RID_DIALOG_MAILMERGE_BTN_INSERT:
{
UT_Win32LocaleString str;
int nChars = getDlgItemText(AP_RID_DIALOG_MAILMERGE_EDIT_FIELD, str);
if (nChars > 0)
{
setMergeField(str.utf8_str ());
addClicked();
}
else
{
int nItem = SendMessageW(GetDlgItem(m_hDlg, AP_RID_DIALOG_MAILMERGE_LISTBOX), LB_GETCURSEL, 0, 0);
if (nItem!=LB_ERR)
{
// get the mail merge field from the listbox
HWND lBox = GetDlgItem(m_hDlg, AP_RID_DIALOG_MAILMERGE_LISTBOX);
UT_sint32 len = SendMessageW(lBox, LB_GETTEXTLEN, nItem, (LPARAM)0);
wchar_t* szBuff = (wchar_t*)g_malloc(sizeof(wchar_t) * (len + 1));
SendMessageW(lBox, LB_GETTEXT, nItem, (LPARAM)szBuff);
str.fromLocale(szBuff);
FREEP(szBuff);
setMergeField(str.utf8_str());
addClicked();
}
}
return 1;
}
case AP_RID_DIALOG_MAILMERGE_BTN_OPEN:
{
eventOpen();
SetFocus(m_hDlg);
return 1;
}
case AP_RID_DIALOG_MAILMERGE_BTN_CLOSE:
case IDCANCEL: // We want to close button work
{
destroy();
return 1;
}
default: // we did not handle this notification
UT_DEBUGMSG(("WM_Command for id %ld\n",wId));
return 0; // return zero to let windows take care of it.
}
}
示例5: LoadLibraryW
int AP_Win32App::WinMain(const char * szAppName, HINSTANCE hInstance,
HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
if (!g_thread_supported ())
g_thread_init (NULL);
bool bShowApp = true;
BOOL bInitialized = FALSE;
// this is a static function and doesn't have a 'this' pointer.
MSG msg;
#ifdef _MSC_VER
_CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_DEBUG );
_CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_DEBUG );
_CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_WNDW);
#endif
// HACK: load least-common-denominator Rich Edit control
// TODO: fix Spell dlg so we don't rely on this
// ALT: make it a Preview widget instead
HINSTANCE hinstRich = LoadLibraryW(L"riched32.dll");
if (!hinstRich)
hinstRich = LoadLibraryW(L"riched20.dll");
UT_return_val_if_fail (hinstRich, 1);
AP_Win32App * pMyWin32App;
// OLE Stuff
if (SUCCEEDED(OleInitialize(NULL)))
bInitialized = TRUE;
// We put this in a block to force the destruction of Args in the stack
{
UT_Win32LocaleString scnv;
UT_UTF8String sUTFCmdLine;
// Load the command line into an XAP_Args class
scnv.fromLocale(GetCommandLineW());
sUTFCmdLine=scnv.utf8_str();
XAP_Args XArgs = XAP_Args(sUTFCmdLine.utf8_str());
// Step 1: Initialize our application.
pMyWin32App = new AP_Win32App(hInstance, szAppName);
AP_Args Args = AP_Args(&XArgs, szAppName, pMyWin32App);
Args.parseOptions();
pMyWin32App->initialize();
// Step 2: Handle all non-window args.
// process args (calls common arg handler, which then calls platform specific)
// As best I understand, it returns true to continue and show window, or
// false if no window should be shown (and thus we should simply exit).
bool windowlessArgsWereSuccessful = true;
if (!Args.doWindowlessArgs(windowlessArgsWereSuccessful))
{
pMyWin32App->shutdown(); // properly shutdown the app 1st
delete pMyWin32App;
return (windowlessArgsWereSuccessful ? 0 : -1);
}
// Step 3: Create windows as appropriate.
// if some args are botched, it returns false and we should
// continue out the door.
// We used to check for bShowApp here. It shouldn't be needed
// anymore, because doWindowlessArgs was supposed to bail already. -PL
if (!pMyWin32App->openCmdLineFiles(&Args))
{
pMyWin32App->shutdown(); // properly shutdown the app 1st
delete pMyWin32App;
return 0;
}
}
//
// This block is controlled by the Structured Exception Handle
// if any crash happens here we will recover it and save the file (cross fingers)
//
try
{
UT_uint32 iHeight = 0, iWidth = 0, t_flag =0;
UT_sint32 iPosX = 0, iPosY = 0;
if (!((XAP_App::getApp()->getGeometry(&iPosX,&iPosY,&iWidth,&iHeight,&t_flag)) &&
((iWidth > 0) && (iHeight > 0))) )
XAP_App::getApp()->getDefaultGeometry(iWidth,iHeight,t_flag);
if ((t_flag & PREF_FLAG_GEOMETRY_MAXIMIZED)==PREF_FLAG_GEOMETRY_MAXIMIZED)
iCmdShow = SW_SHOWMAXIMIZED;
if (bShowApp)
{
// display the windows
for(UT_sint32 i = 0; i < pMyWin32App->m_vecFrames.getItemCount(); i++)
{
AP_Win32Frame * curFrame = (AP_Win32Frame*)pMyWin32App->m_vecFrames[i];
UT_continue_if_fail(curFrame);
//.........这里部分代码省略.........
示例6: DdeGetData
void XAP_Win32Slurp::processCommand(HDDEDATA hData)
{
DWORD bufSize = DdeGetData(hData,NULL,0,0);
char * pBuf = (char *)UT_calloc(sizeof(char),bufSize+100);
if (!pBuf)
{
UT_DEBUGMSG(("No memory to allocate DDE buffer [size %d]\n",bufSize));
return;
}
DdeGetData(hData,(LPBYTE)pBuf,bufSize+99,0);
UT_Win32LocaleString wstr;
UT_UTF8String astr;
wstr.fromLocale((LPCWSTR)pBuf);
astr=wstr.utf8_str();
UT_DEBUGMSG(("DDEML received command '%s'\n",astr.utf8_str()));
// we expect something of the form:
// [Open("<pathname>")]
// if anything more complicated is needed, it may be a
// good idea to use a regex library
// TODO failures just goto Finished. Some error reporting
// TODO would be nice
// pointer to work through the incoming string
const char * next = astr.utf8_str();
// pointer used to copy into command and pathname
char * dest = 0;
// chomp the [
if ( *next++ != '[' ) goto Finished;
// find the next sequence of non ( characters
// this will be the dde command
char command[1024];
dest = command;
for ( ; *next != '('; ++next )
{
*dest++ = *next;
}
*dest = 0;
// chomp the ( and the "
if ( *next++ != '(' ) goto Finished;
if ( *next++ != '"' ) goto Finished;
// go until the next " to get the parameter
// " are not allowed in filenames, so we should be safe here
char pathname[4096];
dest = pathname;
for ( ; *next != '"'; ++next )
{
*dest++ = *next;
}
*dest = 0;
// chomp the ", ), and ]
if ( *next++ != '"' ) goto Finished;
if ( *next++ != ')' ) goto Finished;
if ( *next++ != ']' ) goto Finished;
// now do something useful with the command and its parameter
if (g_ascii_strcasecmp(command,"open") == 0)
{
if (!pathname || !*pathname)
{
UT_DEBUGMSG(("No pathname given in DDE Open command.\n"));
goto Finished;
}
// ask the application to load this document into a window....
// let's create uri for comparison with filenames from command line
// TODO: That method does not always work. Some proper method should
// be designed.
char *uri = UT_go_filename_to_uri(pathname);
XAP_Win32App *p_app = (XAP_Win32App *)XAP_App::getApp();
UT_sint32 ndx = p_app->findFrame(uri);
UT_Error error;
if ((ndx < 0) || p_app->getFrame(ndx)->isDirty()) {
error = p_app->fileOpen(p_app->getLastFocussedFrame(), uri);
}
if(error != UT_OK)
{
UT_DEBUGMSG(("Could not load document given in DDE Open command [%s].\n",uri));
}
FREEP(uri);
goto Finished;
}
Finished:
FREEP(pBuf);
DdeFreeDataHandle(hData);
}
示例7: sizeof
void XAP_Win32Dialog_FontChooser::runModal(XAP_Frame * pFrame)
{
UT_return_if_fail(pFrame);
XAP_Win32App * pApp = static_cast<XAP_Win32App *>(XAP_App::getApp());
UT_return_if_fail(pApp);
const XAP_EncodingManager *pEncMan = pApp->getEncodingManager();
UT_return_if_fail(pEncMan);
UT_Win32LocaleString family;
UT_DEBUGMSG(("FontChooserStart: Family[%s] Size[%s] Weight[%s] Style[%s] Color[%s] Underline[%d] StrikeOut[%d]\n",
m_sFontFamily.c_str(),
m_sFontSize.c_str(),
m_sFontWeight.c_str(),
m_sFontStyle.c_str(),
m_sColor.c_str(),
m_bUnderline,
m_bStrikeout));
m_bWin32Overline = m_bOverline;
m_bWin32Hidden = m_bHidden;
m_bWin32SuperScript = m_bSuperScript;
m_bWin32SubScript = m_bSubScript;
/*
WARNING: any changes to this function should be closely coordinated
with the equivalent logic in Win32Graphics::FindFont()
*/
LOGFONTW lf;
memset(&lf, 0, sizeof(lf));
CHOOSEFONTW cf;
memset(&cf, 0, sizeof(cf));
cf.lStructSize = sizeof(cf);
cf.hwndOwner = static_cast<XAP_Win32FrameImpl*>(pFrame->getFrameImpl())->getTopLevelWindow();
cf.lpLogFont = &lf;
cf.Flags = CF_SCREENFONTS |
CF_EFFECTS |
CF_ENABLEHOOK |
CF_ENABLETEMPLATE |
CF_INITTOLOGFONTSTRUCT;
cf.lpTemplateName = MAKEINTRESOURCEW(XAP_RID_DIALOG_FONT);
cf.lpfnHook = (LPCFHOOKPROC) s_hookProc;
cf.lCustData = (LPARAM) this;
cf.hInstance = pApp->getInstance();
if (!m_sFontFamily.empty())
{
family.fromUTF8 (m_sFontFamily.c_str());
lstrcpynW(lf.lfFaceName,family.c_str(),LF_FACESIZE);
}
else
cf.Flags |= CF_NOFACESEL;
if (!m_sFontSize.empty())
{
UT_ASSERT(sizeof(char) == sizeof(gchar));
lf.lfHeight = (long) -(UT_convertToPoints(m_sFontSize.c_str()))*4/3;
}
else
cf.Flags |= CF_NOSIZESEL;
if (!m_sFontWeight.empty())
{
if (g_ascii_strcasecmp(m_sFontWeight.c_str(),"bold") == 0)
lf.lfWeight = 700;
// TODO do we need any others here...
}
else
cf.Flags |= CF_NOSTYLESEL;
if (!m_sFontStyle.empty())
{
if (g_ascii_strcasecmp(m_sFontStyle.c_str(),"italic") == 0)
lf.lfItalic = TRUE;
}
else
cf.Flags |= CF_NOSTYLESEL;
if (!m_sColor.empty())
{
UT_RGBColor c;
UT_parseColor(m_sColor.c_str(),c);
cf.rgbColors = RGB(c.m_red,c.m_grn,c.m_blu);
}
if (m_bUnderline)
lf.lfUnderline = TRUE;
if (m_bStrikeout)
lf.lfStrikeOut = TRUE;
// run the actual dialog...
m_answer = (ChooseFontW(&cf) ? a_OK : a_CANCEL);
// Convert the font name returned by the Windows Font Chooser
// to UTF-8.
family.fromLocale (lf.lfFaceName);
UT_UTF8String family_utf = family.utf8_str();
const char *szFontFamily = family_utf.utf8_str();
//.........这里部分代码省略.........
示例8: HIWORD
BOOL AP_Win32Dialog_Columns::_onCommand(HWND hWnd, WPARAM wParam, LPARAM /*lParam*/)
{
WORD wNotifyCode = HIWORD(wParam);
WORD wId = LOWORD(wParam);
wchar_t buf[BUFSIZE];
UT_Win32LocaleString str;
switch (wId)
{
case IDCANCEL: // also AP_RID_DIALOG_COLUMN_BTN_CANCEL
m_answer = a_CANCEL;
// fall through
case IDOK: // also AP_RID_DIALOG_COLUMN_BTN_OK
EndDialog(hWnd,0);
return 1;
case AP_RID_DIALOG_COLUMN_RADIO_ONE:
setColumns(1);
checkButton(AP_RID_DIALOG_COLUMN_RADIO_TWO, false);
checkButton(AP_RID_DIALOG_COLUMN_RADIO_THREE, false);
SetDlgItemTextW(m_hDlg, AP_RID_DIALOG_COLUMN_EDIT_NUMCOLUMNS, _itow(getColumns(),buf,10));
return 1;
case AP_RID_DIALOG_COLUMN_RADIO_TWO:
setColumns(2);
checkButton(AP_RID_DIALOG_COLUMN_RADIO_ONE, false);
checkButton(AP_RID_DIALOG_COLUMN_RADIO_THREE, false);
SetDlgItemTextW(m_hDlg, AP_RID_DIALOG_COLUMN_EDIT_NUMCOLUMNS, _itow(getColumns(),buf,10));
return 1;
case AP_RID_DIALOG_COLUMN_RADIO_THREE:
setColumns(3);
checkButton(AP_RID_DIALOG_COLUMN_RADIO_ONE, false);
checkButton(AP_RID_DIALOG_COLUMN_RADIO_TWO, false);
SetDlgItemTextW(m_hDlg, AP_RID_DIALOG_COLUMN_EDIT_NUMCOLUMNS, _itow(getColumns(),buf,10));
return 1;
case AP_RID_DIALOG_COLUMN_CHECK_LINE_BETWEEN:
setLineBetween( isChecked(AP_RID_DIALOG_COLUMN_CHECK_LINE_BETWEEN)==BST_CHECKED );
return 1;
case AP_RID_DIALOG_COLUMN_EDIT_NUMCOLUMNS:
if( wNotifyCode == EN_KILLFOCUS )
{
GetDlgItemTextW( hWnd, wId, buf, BUFSIZE );
if( _wtoi( buf ) > 0 && _wtoi(buf) != (signed) getColumns() )
{
setColumns( _wtoi(buf) );
}
SetDlgItemTextW(m_hDlg, wId, _itow(getColumns(),buf,10));
checkButton(AP_RID_DIALOG_COLUMN_RADIO_ONE, (getColumns()==1));
checkButton(AP_RID_DIALOG_COLUMN_RADIO_TWO, (getColumns()==2));
checkButton(AP_RID_DIALOG_COLUMN_RADIO_THREE, (getColumns()==3));
}
return 1;
case AP_RID_DIALOG_COLUMN_EDIT_SPACEAFTER:
if( wNotifyCode == EN_KILLFOCUS )
{
GetDlgItemTextW( hWnd, wId, buf, BUFSIZE );
str.fromLocale (buf);
setSpaceAfter( str.utf8_str().utf8_str() );
str.fromUTF8 (getSpaceAfterString ());
SetDlgItemTextW(m_hDlg, wId, str.c_str ());
}
return 1;
case AP_RID_DIALOG_COLUMN_EDIT_MAXSIZE:
if( wNotifyCode == EN_KILLFOCUS )
{
GetDlgItemTextW( hWnd, wId, buf, BUFSIZE );
str.fromLocale (buf);
setMaxHeight( str.utf8_str().utf8_str() );
str.fromUTF8 (getHeightString());
SetDlgItemTextW(m_hDlg, wId, str.c_str ());
}
return 1;
case AP_RID_DIALOG_COLUMN_CHECK_RTL_ORDER:
setColumnOrder( (UT_uint32) (isChecked(AP_RID_DIALOG_COLUMN_CHECK_RTL_ORDER) == BST_CHECKED) );
return 1;
default: // we did not handle this notification
UT_DEBUGMSG(("WM_Command for id %ld\n",wId));
return 0; // return zero to let windows take care of it.
}
}