本文整理汇总了C++中WString::GetCount方法的典型用法代码示例。如果您正苦于以下问题:C++ WString::GetCount方法的具体用法?C++ WString::GetCount怎么用?C++ WString::GetCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WString
的用法示例。
在下文中一共展示了WString::GetCount方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sSwapCase
static WString sSwapCase(const WString& s)
{
WStringBuffer r;
r.SetCount(s.GetCount());
for(int i = 0; i < s.GetCount(); i++)
r[i] = IsUpper(s[i]) ? ToLower(s[i]) : ToUpper(s[i]);
return r;
}
示例2: Paint
virtual void Paint(Draw& w) {
WString h = "Hello ěščřžýáíéúů ";
for(int i = 0; i < 10; i++)
h.Cat(20000 + i);
w.DrawRect(GetSize(), White());
Font fnt;
fnt.FaceName("Bitstream Vera Sans Mono");
fnt.Height(13);
DoDrawText(w, 100, 100, 0, h, fnt, Black(), h.GetCount(), NULL);
DoDrawText(w, 100, 300, 300, h, fnt, Black(), h.GetCount(), NULL);
}
示例3: EndPart
void RichQtfParser::EndPart()
{
if(istable) {
if(paragraph.GetCount() == 0 && text.GetCount() == 0)
if(table.GetCount())
table.Top().text.CatPick(pick(tablepart));
else
target.CatPick(pick(tablepart));
else {
paragraph.part.Clear();
text.Clear();
}
}
else {
Flush();
bool b = paragraph.format.newpage;
if(breakpage)
paragraph.format.newpage = true;
if(table.GetCount())
table.Top().text.Cat(paragraph, target.GetStyles());
else
target.Cat(paragraph);
paragraph.part.Clear();;
paragraph.format.newpage = b;
SetFormat();
breakpage = false;
}
istable = false;
}
示例4: sMergeWith
static void sMergeWith(WString& dest, const wchar *delim, const WString& s)
{
if(s.GetLength()) {
if(dest.GetCount())
dest.Cat(delim);
dest.Cat(s);
}
}
示例5: SpellerAdd
void RichEdit::SpellerAdd(const WString& w, int lang)
{
if(!SpellWord(w, w.GetCount(), lang)) {
Speller *f = sGetSpeller(lang);
if(f) {
FileAppend fa(sUserFile(lang));
fa.PutLine(ToUtf8(w));
f->user.Add(w);
speller_cache.Clear();
}
}
}
示例6: AppendFiles
void AppendFiles(VectorMap<String, ClipData>& clip, const Vector<String>& files)
{
WString wfiles;
for(int i = 0; i < files.GetCount(); i++)
wfiles << files[i].ToWString() << "\0";
sDROPFILES h;
h.unicode = true;
h.offset = sizeof(h);
GetCursorPos(&h.pt);
h.nc = TRUE;
String data;
data.Cat((byte *)&h, sizeof(h));
data.Cat((byte *)~wfiles, 2 * (wfiles.GetCount() + 1));
clip.GetAdd("files") = ClipData(data);
}
示例7: GetSize
void LineEdit::Paint0(Draw& w) {
int sell, selh;
GetSelection(sell, selh);
if(!IsEnabled())
sell = selh = 0;
Size sz = GetSize();
Size fsz = GetFontSize();
Point sc = sb;
int ll = min(line.GetCount(), sz.cy / fsz.cy + sc.y + 1);
int y = 0;
cpos = GetPos(sc.y);
cline = sc.y;
sell -= cpos;
selh -= cpos;
int pos = cpos;
Vector<int> dx, dx2;
int fascent = font.Info().GetAscent();
for(int i = sc.y; i < ll; i++) {
WString tx = line[i];
int len = tx.GetLength();
if(w.IsPainting(0, y, sz.cx, fsz.cy)) {
Highlight ih;
ih.ink = color[IsShowEnabled() ? INK_NORMAL : INK_DISABLED];
ih.paper = color[IsReadOnly() || !IsShowEnabled() ? PAPER_READONLY : PAPER_NORMAL];
if(nobg)
ih.paper = Null;
ih.font = font;
ih.chr = 0;
Vector<Highlight> hl;
hl.SetCount(len + 1, ih);
for(int q = 0; q < tx.GetCount(); q++)
hl[q].chr = tx[q];
HighlightLine(i, hl, pos);
int ln = hl.GetCount() - 1;
int l = max(sell, 0);
int h = selh > len ? len : selh;
if(l < h)
for(int i = l; i < h; i++) {
hl[i].paper = color[PAPER_SELECTED];
hl[i].ink = color[INK_SELECTED];
}
if(sell <= len && selh > len)
for(int i = len; i < hl.GetCount(); i++) {
hl[i].paper = color[PAPER_SELECTED];
hl[i].ink = color[INK_SELECTED];
}
Buffer<wchar> txt(ln);
for(int i = 0; i < ln; i++)
txt[i] = hl[i].chr;
for(int pass = 0; pass < 2; pass++) {
int gp = 0;
int scx = fsz.cx * sc.x;
if(ln >= 0) {
int q = 0;
while(q < ln) {
Highlight& h = hl[q];
if(txt[q] == '\t') {
int ngp = (gp + tabsize) / tabsize * tabsize;
int l = ngp - gp;
LLOG("Highlight -> tab[" << q << "] paper = " << h.paper);
if(pass == 0) {
w.DrawRect(gp * fsz.cx - scx, y, fsz.cx * l, fsz.cy, h.paper);
if(showtabs && h.paper != SColorHighlight && q < tx.GetLength()) {
Color c = Blend(SColorLight, SColorHighlight);
w.DrawRect(gp * fsz.cx - scx + 2, y + fsz.cy / 2,
l * fsz.cx - 4, 1, c);
w.DrawRect(ngp * fsz.cx - scx - 3, y + 3,
1, fsz.cy - 6, c);
}
if(bordercolumn > 0 && bordercolumn >= gp && bordercolumn < gp + l)
w.DrawRect((bordercolumn - sc.x) * fsz.cx, y, 1, fsz.cy, bordercolor);
}
q++;
gp = ngp;
}
else
if(txt[q] == ' ') {
LLOG("Highlight -> space[" << q << "] paper = " << h.paper);
if(pass == 0) {
w.DrawRect(gp * fsz.cx - scx, y, fsz.cx, fsz.cy, h.paper);
if(showspaces && h.paper != SColorHighlight && q < tx.GetLength()) {
Color c = Blend(SColorLight, SColorHighlight);
w.DrawRect(gp * fsz.cx - scx + fsz.cx / 2, y + fsz.cy / 2,
2, 2, c);
}
if(bordercolumn > 0 && bordercolumn >= gp && bordercolumn < gp + 1)
w.DrawRect((bordercolumn - sc.x) * fsz.cx, y, 1, fsz.cy, bordercolor);
}
q++;
gp++;
}
else {
bool cjk = IsCJKIdeograph(txt[q]);
int p = q + 1;
while(p < len && h == hl[p] && txt[p] != '\t' && txt[p] != ' ' && IsCJKIdeograph(txt[p]) == cjk && p - q < 128)
p++;
int l = p - q;
int ll = cjk ? 2 * l : l;
LLOG("Highlight -> paper[" << q << "] = " << h.paper);
int x = gp * fsz.cx - scx;
//.........这里部分代码省略.........
示例8: Text
Painter& Painter::Text(const Pointf& p, const char *text, Font fnt, int n, double *dx)
{
WString s = ToUnicode(text, CHARSET_DEFAULT);
return Text(p, s, fnt, n < 0 ? s.GetCount() : n, dx);
}
示例9: Proc
//.........这里部分代码省略.........
else
GtkButtonEvent(UP);
break;
case GDK_SCROLL: {
GtkMouseEvent(MOUSEWHEEL, MOUSEWHEEL, CurrentEvent.value);
break;
}
case GDK_KEY_PRESS:
pressed = true;
case GDK_KEY_RELEASE:
kv = CurrentEvent.value;
if(kv >= 0 && kv < 65536) {
LLOG("keyval " << FormatIntHex(kv) << ' ' << (char)kv);
if(kv >= 'a' && kv <= 'z')
kv = kv - 'a' + 'A';
static Tuple2<int, int> cv[] = {
{ GDKEY(BackSpace), K_BACKSPACE },
{ GDKEY(Tab), K_TAB },
{ GDKEY(ISO_Left_Tab), K_TAB },
{ GDKEY(Return), K_ENTER },
{ GDKEY(Escape), K_ESCAPE },
{ GDKEY(space), K_SPACE },
{ GDKEY(Control_L), K_CTRL_KEY },
{ GDKEY(Control_R), K_CTRL_KEY },
{ GDKEY(Shift_L), K_SHIFT_KEY },
{ GDKEY(Shift_R), K_SHIFT_KEY },
{ GDKEY(Alt_L), K_ALT_KEY },
{ GDKEY(Alt_R), K_ALT_KEY },
{ GDKEY(KP_Space), K_SPACE },
{ GDKEY(KP_Tab), K_TAB },
{ GDKEY(KP_Enter), K_ENTER },
{ GDKEY(KP_F1), K_F1 },
{ GDKEY(KP_F2), K_F2 },
{ GDKEY(KP_F3), K_F3 },
{ GDKEY(KP_F4), K_F4 },
{ GDKEY(KP_Home), K_HOME },
{ GDKEY(KP_Left), K_LEFT },
{ GDKEY(KP_Up), K_UP },
{ GDKEY(KP_Right), K_RIGHT },
{ GDKEY(KP_Down), K_DOWN },
{ GDKEY(KP_Page_Up), K_PAGEUP },
{ GDKEY(KP_Page_Down), K_PAGEDOWN },
{ GDKEY(KP_End), K_END },
{ GDKEY(KP_Begin), K_HOME },
{ GDKEY(KP_Insert), K_INSERT },
{ GDKEY(KP_Delete), K_DELETE },
};
Tuple2<int, int> *x = FindTuple(cv, __countof(cv), kv);
if(x)
kv = x->b;
else
kv += K_DELTA;
if(GetShift() && kv != K_SHIFT_KEY)
kv |= K_SHIFT;
if(GetCtrl() && kv != K_CTRL_KEY)
kv |= K_CTRL;
if(GetAlt() && kv != K_ALT_KEY)
kv |= K_ALT;
LLOG(GetKeyDesc(kv) << ", pressed: " << pressed << ", count: " << CurrentEvent.count);
#ifdef GDK_WINDOWING_X11
if(pressed)
for(int i = 0; i < hotkey.GetCount(); i++) {
if(hotkey[i] && keyhot[i] == (dword)kv) {
hotkey[i]();
return;
}
}
#endif
DispatchKey(!pressed * K_KEYUP + kv, CurrentEvent.count);
}
break;
case EVENT_TEXT: {
WString h = CurrentEvent.value;
for(int i = 0; i < h.GetCount(); i++) // TODO: Add compression
DispatchKey(h[i], 1);
break;
}
case GDK_DELETE: {
TopWindow *w = dynamic_cast<TopWindow *>(this);
if(w) {
if(IsEnabled()) {
IgnoreMouseUp();
w->WhenClose();
}
}
return;
}
case GDK_CONFIGURE: {
Rect rect = CurrentEvent.value;
if(GetRect() != rect)
SetWndRect(rect);
}
break;
default:
return;
}
if(_this)
_this->PostInput();
}
示例10: rw
void LineEdit::Paint0(Draw& w) {
LTIMING("LineEdit::Paint0");
int sell, selh;
GetSelection(sell, selh);
if(!IsEnabled())
sell = selh = 0;
Rect rect;
bool rectsel = IsRectSelection();
if(IsRectSelection())
rect = GetRectSelection();
Size sz = GetSize();
Size fsz = GetFontSize();
Point sc = sb;
int ll = min(line.GetCount(), sz.cy / fsz.cy + sc.y + 1);
int y = 0;
sc.y = minmax(sc.y, 0, line.GetCount() - 1);
cpos = GetPos(sc.y);
cline = sc.y;
sell -= cpos;
selh -= cpos;
int pos = cpos;
int fascent = font.Info().GetAscent();
int cursorline = GetLine(cursor);
Highlight ih;
ih.ink = color[IsShowEnabled() ? INK_NORMAL : INK_DISABLED];
ih.paper = color[IsReadOnly() && showreadonly || !IsShowEnabled() ? PAPER_READONLY : PAPER_NORMAL];
if(nobg)
ih.paper = Null;
ih.font = font;
ih.chr = 0;
for(int i = sc.y; i < ll; i++) {
Color showcolor = color[WHITESPACE];
WString tx = line[i];
bool warn_whitespace = false;
if(warnwhitespace && !IsSelection()) {
int pos = GetCursor();
int linei = GetLinePos(pos);
if(linei != i || pos < tx.GetCount()) {
int wkind = 0;
bool empty = true;
for(const wchar *s = tx; *s; s++) {
if(*s == '\t') {
if(wkind == ' ') {
warn_whitespace = true;
break;
}
wkind = '\t';
}
else
if(*s == ' ')
wkind = ' ';
else
if(*s > ' ') {
empty = false;
wkind = 0;
}
}
if(wkind && !empty)
warn_whitespace = true;
if(warn_whitespace)
showcolor = color[WARN_WHITESPACE];
}
}
bool do_highlight = tx.GetCount() < 100000;
int len = tx.GetLength();
if(w.IsPainting(0, y, sz.cx, fsz.cy)) {
LTIMING("PaintLine");
Vector<Highlight> hl;
int ln;
if(do_highlight) {
hl.SetCount(len + 1, ih);
for(int q = 0; q < tx.GetCount(); q++)
hl[q].chr = tx[q];
LTIMING("HighlightLine");
HighlightLine(i, hl, pos);
ln = hl.GetCount() - 1;
}
else
ln = tx.GetCount();
int lgp = -1;
for(int pass = 0; pass < 2; pass++) {
int gp = 0;
int scx = fsz.cx * sc.x;
sOptimizedRectRenderer rw(w);
if(ln >= 0) {
int q = 0;
int x = 0;
int scx2 = scx - max(2, tabsize) * fsz.cx;
while(q < ln && x < scx2) { // Skip part before left border
wchar chr = do_highlight ? hl[q++].chr : tx[q++];
if(chr == '\t') {
gp = (gp + tabsize) / tabsize * tabsize;
x = fsz.cx * gp;
}
else
if(IsCJKIdeograph(chr)) {
x += 2 * fsz.cx;
gp += 2;
}
else {
//.........这里部分代码省略.........