本文整理汇总了C++中FXString::assign方法的典型用法代码示例。如果您正苦于以下问题:C++ FXString::assign方法的具体用法?C++ FXString::assign怎么用?C++ FXString::assign使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FXString
的用法示例。
在下文中一共展示了FXString::assign方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: next
// Go to next directory entry and return its name
FXbool FXDir::next(FXString& name){
if(isOpen()){
#ifdef WIN32
if(((SPACE*)space)->first || FindNextFile(((SPACE*)space)->handle,&((SPACE*)space)->result)){
((SPACE*)space)->first=false;
name.assign(((SPACE*)space)->result.cFileName);
return true;
}
#else
#if defined(FOX_THREAD_SAFE) && !defined(__FreeBSD__) && !defined(__OpenBSD__)
if(!readdir_r(((SPACE*)space)->handle,&((SPACE*)space)->result,&((SPACE*)space)->dp) && ((SPACE*)space)->dp){
name.assign(((SPACE*)space)->dp->d_name);
return true;
}
#else
if((((SPACE*)space)->dp=readdir(((SPACE*)space)->handle))!=NULL){
name.assign(((SPACE*)space)->dp->d_name);
return true;
}
#endif
#endif
}
name.clear();
return false;
}
示例2: onClipboardRequest
// Somebody wants our clipped text
long TextLabel::onClipboardRequest(FXObject* sender,FXSelector sel,void* ptr)
{
FXEvent *event=(FXEvent*)ptr;
FXString string;
// Perhaps the target wants to supply its own data for the clipboard
if (FXFrame::onClipboardRequest(sender,sel,ptr))
return 1;
// Recognize the request?
if (event->target==stringType || event->target==textType || event->target==utf8Type || event->target==utf16Type)
{
// Get clipped string
string=clipped;
// If password mode, replace by stars
if (options&TEXTFIELD_PASSWD)
string.assign('*',string.count());
// Return clipped text as as UTF-8
if (event->target==utf8Type)
{
setDNDData(FROM_CLIPBOARD,event->target,string);
return 1;
}
// Return clipped text translated to 8859-1
if (event->target==stringType || event->target==textType)
{
FX88591Codec ascii;
setDNDData(FROM_CLIPBOARD,event->target,ascii.utf2mb(string));
return 1;
}
// Return text of the selection translated to UTF-16
if (event->target==utf16Type)
{
FXUTF16LECodec unicode; // FIXME maybe other endianness for unix
setDNDData(FROM_CLIPBOARD,event->target,unicode.utf2mb(string));
return 1;
}
}
return 0;
}
示例3: GetFilenameFromSelection
// Check for an already-selected filename
static void GetFilenameFromSelection(FXMainWindow*tw,SciDoc*sci, FXString &filename)
{
#ifdef WIN32
sci->GetSelText(filename);
#else // On X11 platforms, try first to get a filename from the X-Selection
FXuchar*xsel=NULL;
FXuint xlen=0;
FXDragType types[] = { tw->textType, tw->utf8Type, tw->stringType, 0 };
for ( FXDragType*type=types; *type; type++ ) {
if (tw->getDNDData(FROM_SELECTION,*type, xsel, xlen) && xsel && *xsel) {
FXuchar*eol=(FXuchar*)memchr(xsel,'\n', xlen);
FXuint n = eol ? (eol-xsel) : xlen;
filename.assign((FXchar*)xsel,n);
filename=filename.simplify();
if (!FXStat::exists(filename.contains(':')?filename.section(':',0):filename)) {
filename=FXString::null;
}
break;
}
if ( filename.empty() ) { sci->GetSelText(filename); }
}
#endif
}
示例4: onSelectionRequest
// Somebody wants our selection; the text field will furnish it if the target doesn't
long TextLabel::onSelectionRequest(FXObject* sender,FXSelector sel,void* ptr)
{
FXEvent *event=(FXEvent*)ptr;
FXString string;
FXuint start;
FXuint len;
// Make sure
FXASSERT(0<=anchor && anchor<=contents.length());
FXASSERT(0<=cursor && cursor<=contents.length());
// Perhaps the target wants to supply its own data for the selection
if (FXFrame::onSelectionRequest(sender,sel,ptr))
return 1;
// Recognize the request?
if (event->target==stringType || event->target==textType || event->target==utf8Type || event->target==utf16Type)
{
// Figure selected bytes
if (anchor<cursor)
{
start=anchor;
len=cursor-anchor;
}
else
{
start=cursor;
len=anchor-cursor;
}
// Get selected fragment
string=contents.mid(start,len);
// If password mode, replace by stars
if (options&TEXTFIELD_PASSWD)
string.assign('*',string.count());
// Return text of the selection as UTF-8
if (event->target==utf8Type)
{
setDNDData(FROM_SELECTION,event->target,string);
return 1;
}
// Return text of the selection translated to 8859-1
if (event->target==stringType || event->target==textType)
{
FX88591Codec ascii;
setDNDData(FROM_SELECTION,event->target,ascii.utf2mb(string));
return 1;
}
// Return text of the selection translated to UTF-16
if (event->target==utf16Type)
{
FXUTF16LECodec unicode; // FIXME maybe other endianness for unix
setDNDData(FROM_SELECTION,event->target,unicode.utf2mb(string));
return 1;
}
}
return 0;
}