32#pragma warning(disable: 4266)
34#include <FX88591Codec.h>
35#include <FXUTF16Codec.h>
47#define JUSTIFY_MASK (JUSTIFY_HZ_APART|JUSTIFY_VT_APART)
48#define TEXTFIELD_MASK (TEXTFIELD_PASSWD|TEXTFIELD_INTEGER|TEXTFIELD_REAL|TEXTFIELD_READONLY|TEXTFIELD_ENTER_ONLY|TEXTFIELD_LIMITED|TEXTFIELD_OVERSTRIKE|TEXTFIELD_AUTOHIDE|TEXTFIELD_AUTOGRAY)
85 FXMAPFUNC(SEL_UPDATE, FXTextField::ID_PASTE_SEL, MFXTextFieldIcon::onUpdYes),
126FXIMPLEMENT(
MFXTextFieldIcon, FXFrame, MFXTextFieldIconMap, ARRAYNUMBER(MFXTextFieldIconMap))
133 FXuint opts, FXint x, FXint y, FXint w, FXint h, FXint pl, FXint pr, FXint pt, FXint pb) :
134 FXFrame(p, opts, x, y, w, h, pl, pr, pt, pb),
139 flags |= FLAG_ENABLED;
142 if (!(options & JUSTIFY_RIGHT)) {
143 options |= JUSTIFY_LEFT;
145 defaultCursor = getApp()->getDefaultCursor(DEF_TEXT_CURSOR);
146 dragCursor = getApp()->getDefaultCursor(DEF_TEXT_CURSOR);
147 font = getApp()->getNormalFont();
148 backColor = getApp()->getBackColor();
149 textColor = getApp()->getForeColor();
150 selbackColor = getApp()->getSelbackColor();
151 seltextColor = getApp()->getSelforeColor();
152 cursorColor = getApp()->getForeColor();
158 getApp()->removeTimeout(
this, FXTextField::ID_BLINK);
159 getApp()->removeTimeout(
this, ID_AUTOSCROLL);
160 font = (FXFont*) - 1L;
168 textType = getApp()->registerDragType(textTypeName);
171 utf8Type = getApp()->registerDragType(utf8TypeName);
174 utf16Type = getApp()->registerDragType(utf16TypeName);
183 fxerror(
"%s::setFont: NULL font specified.\n", getClassName());
195 if (!(flags & FLAG_ENABLED)) {
204 if (flags & FLAG_ENABLED) {
213 return padleft + padright + (border << 1) +
columns *
font->getTextWidth(
"8", 1);
220 return padtop + padbottom + (border << 1) +
font->getFontHeight();
226 if (!FXFrame::onUpdate(sender, sel, ptr)) {
227 if (options & TEXTFIELD_AUTOHIDE) {
233 if (options & TEXTFIELD_AUTOGRAY) {
243 FXFrame::onSelectionGained(sender, sel, ptr);
251 FXFrame::onSelectionLost(sender, sel, ptr);
259 FXEvent*
event = (FXEvent*)ptr;
269 if (FXFrame::onSelectionRequest(sender, sel, ptr)) {
274 if (event->target == stringType || event->target == textType || event->target == utf8Type || event->target == utf16Type) {
289 if (options & TEXTFIELD_PASSWD) {
290 string.assign(
'*',
string.count());
294 if (event->target == utf8Type) {
295 FXTRACE((100,
"Request UTF8\n"));
296 setDNDData(FROM_SELECTION, event->target,
string);
301 if (event->target == stringType || event->target == textType) {
303 FXTRACE((100,
"Request ASCII\n"));
304 setDNDData(FROM_SELECTION, event->target, ascii.utf2mb(
string));
309 if (event->target == utf16Type) {
310 FXUTF16LECodec unicode;
311 FXTRACE((100,
"Request UTF16\n"));
312 setDNDData(FROM_SELECTION, event->target, unicode.utf2mb(
string));
322 FXFrame::onClipboardGained(sender, sel, ptr);
329 FXFrame::onClipboardLost(sender, sel, ptr);
338 FXEvent*
event = (FXEvent*)ptr;
342 if (FXFrame::onClipboardRequest(sender, sel, ptr)) {
347 if (event->target == stringType || event->target == textType || event->target == utf8Type || event->target == utf16Type) {
353 if (options & TEXTFIELD_PASSWD) {
354 string.assign(
'*',
string.count());
358 if (event->target == utf8Type) {
359 FXTRACE((100,
"Request UTF8\n"));
360 setDNDData(FROM_CLIPBOARD, event->target,
string);
365 if (event->target == stringType || event->target == textType) {
367 FXTRACE((100,
"Request ASCII\n"));
368 setDNDData(FROM_CLIPBOARD, event->target, ascii.utf2mb(
string));
373 if (event->target == utf16Type) {
374 FXUTF16LECodec unicode;
375 FXTRACE((100,
"Request UTF16\n"));
376 setDNDData(FROM_CLIPBOARD, event->target, unicode.utf2mb(
string));
387 getApp()->addTimeout(
this, FXTextField::ID_BLINK, getApp()->getBlinkSpeed());
394 FXFrame::onFocusIn(sender, sel, ptr);
396 getApp()->addTimeout(
this, FXTextField::ID_BLINK, getApp()->getBlinkSpeed());
399 if (hasSelection()) {
400 update(border, border, width - (border << 1), height - (border << 1));
408 FXFrame::onFocusOut(sender, sel, ptr);
409 getApp()->removeTimeout(
this, FXTextField::ID_BLINK);
411 if (hasSelection()) {
412 update(border, border, width - (border << 1), height - (border << 1));
420 if (FXFrame::onFocusSelf(sender, sel, ptr)) {
421 FXEvent*
event = (FXEvent*)ptr;
422 if (event->type == SEL_KEYPRESS || event->type == SEL_KEYRELEASE) {
423 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_SELECT_ALL), NULL);
441 flags &= ~FLAG_UPDATE;
442 if (getApp()->hasInputMethod()) {
443 createComposeContext();
450 FXFrame::killFocus();
452 flags |= FLAG_UPDATE;
453 if (flags & FLAG_CHANGED) {
454 flags &= ~FLAG_CHANGED;
455 if (!(options & TEXTFIELD_ENTER_ONLY)) {
457 target->tryHandle(
this, FXSEL(SEL_COMMAND, message), (
void*)
contents.text());
461 if (getApp()->hasInputMethod()) {
462 destroyComposeContext();
497 if (FXWindow::onQueryTip(sender, sel, ptr)) {
500 if ((flags & FLAG_TIP) && !
tip.empty()) {
501 sender->handle(
this, FXSEL(SEL_COMMAND, ID_SETSTRINGVALUE), (
void*)&
tip);
510 if (FXWindow::onQueryHelp(sender, sel, ptr)) {
513 if ((flags & FLAG_HELP) && !
help.empty()) {
514 sender->handle(
this, FXSEL(SEL_COMMAND, ID_SETSTRINGVALUE), (
void*)&
help);
530 setText(FXStringVal(*((FXint*)ptr)));
537 setText(FXStringVal(*((FXdouble*)ptr)));
551 *((FXint*)ptr) = FXIntVal(
contents);
558 *((FXdouble*)ptr) = FXDoubleVal(
contents);
572 FXEvent* ev = (FXEvent*)ptr;
574 handle(
this, FXSEL(SEL_FOCUS_SELF, 0), ptr);
577 if (target && target->tryHandle(
this, FXSEL(SEL_LEFTBUTTONPRESS, message), ptr)) {
580 flags &= ~FLAG_UPDATE;
581 if (ev->click_count == 1) {
583 if (ev->state & SHIFTMASK) {
590 flags |= FLAG_PRESSED;
607 flags &= ~FLAG_PRESSED;
609 target->tryHandle(
this, FXSEL(SEL_LEFTBUTTONRELEASE, message), ptr);
619 FXEvent* ev = (FXEvent*)ptr;
621 handle(
this, FXSEL(SEL_FOCUS_SELF, 0), ptr);
624 if (target && target->tryHandle(
this, FXSEL(SEL_MIDDLEBUTTONPRESS, message), ptr)) {
630 update(border, border, width - (border << 1), height - (border << 1));
631 flags &= ~FLAG_UPDATE;
642 if (target && target->tryHandle(
this, FXSEL(SEL_MIDDLEBUTTONRELEASE, message), ptr)) {
645 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_PASTE_MIDDLE), NULL);
653 FXEvent*
event = (FXEvent*)ptr;
655 if (flags & FLAG_PRESSED) {
656 if (event->win_x < (border + padleft) || (width - border - padright) < event->win_x) {
657 if (!getApp()->hasTimeout(
this, ID_AUTOSCROLL)) {
658 getApp()->addTimeout(
this, ID_AUTOSCROLL, getApp()->getScrollSpeed(), event);
661 getApp()->removeTimeout(
this, ID_AUTOSCROLL);
662 t =
index(event->win_x);
677 FXEvent*
event = (FXEvent*)ptr;
678 if (flags & FLAG_PRESSED) {
680 FXint ll = border + padleft;
681 FXint rr = width - border - padright;
685 if (options & TEXTFIELD_PASSWD) {
692 if (options & JUSTIFY_RIGHT) {
695 if (event->win_x < ll) {
697 shift += ll -
event->win_x;
698 if (ww > tw -
shift) {
701 getApp()->addTimeout(
this, ID_AUTOSCROLL, getApp()->getScrollSpeed(), event);
704 newcursor =
index(ll);
708 if (rr < event->win_x) {
710 shift += rr -
event->win_x;
714 getApp()->addTimeout(
this, ID_AUTOSCROLL, getApp()->getScrollSpeed(), event);
717 newcursor =
index(rr);
722 else if (options & JUSTIFY_LEFT) {
725 if (event->win_x < ll) {
727 shift += ll -
event->win_x;
731 getApp()->addTimeout(
this, ID_AUTOSCROLL, getApp()->getScrollSpeed(), event);
734 newcursor =
index(ll);
738 if (rr < event->win_x) {
740 shift += rr -
event->win_x;
741 if (
shift + tw < ww) {
744 getApp()->addTimeout(
this, ID_AUTOSCROLL, getApp()->getScrollSpeed(), event);
747 newcursor =
index(rr);
751 if (event->win_x < ll) {
753 shift += ll -
event->win_x;
754 if (
shift > tw / 2 - ww / 2) {
755 shift = tw / 2 - ww / 2;
757 getApp()->addTimeout(
this, ID_AUTOSCROLL, getApp()->getScrollSpeed(), event);
760 newcursor =
index(ll);
763 if (rr < event->win_x) {
765 shift += rr -
event->win_x;
766 if (
shift < (ww - ww / 2) - tw / 2) {
767 shift = (ww - ww / 2) - tw / 2;
769 getApp()->addTimeout(
this, ID_AUTOSCROLL, getApp()->getScrollSpeed(), event);
772 newcursor =
index(rr);
776 if (newcursor !=
cursor) {
795 sender->handle(
this,
isOverstrike() ? FXSEL(SEL_COMMAND, ID_CHECK) : FXSEL(SEL_COMMAND, ID_UNCHECK), NULL);
796 sender->handle(
this, FXSEL(SEL_COMMAND, ID_SHOW), NULL);
797 sender->handle(
this, FXSEL(SEL_COMMAND, ID_ENABLE), NULL);
811 sender->handle(
this,
isEditable() ? FXSEL(SEL_COMMAND, ID_CHECK) : FXSEL(SEL_COMMAND, ID_UNCHECK), NULL);
812 sender->handle(
this, FXSEL(SEL_COMMAND, ID_SHOW), NULL);
813 sender->handle(
this, FXSEL(SEL_COMMAND, ID_ENABLE), NULL);
820 sender->handle(
this, hasSelection() ? FXSEL(SEL_COMMAND, ID_ENABLE) : FXSEL(SEL_COMMAND, ID_DISABLE), ptr);
827 sender->handle(
this,
contents.empty() ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE), ptr);
853 FXint cl, ch, xx, xlo, xhi;
854 if ((state ^ flags) & FLAG_CARET) {
865 xlo = FXMAX(xx - 2, border);
866 xhi = FXMIN(xx + 3, width - border);
868 dc.setClipRectangle(xlo, border, xhi - xlo, height - (border << 1));
870 if (state & FLAG_CARET) {
873 dc.fillRectangle(xx, padtop + border, 1, height - padbottom - padtop - (border << 1));
874 dc.fillRectangle(xx - 2, padtop + border, 5, 1);
875 dc.fillRectangle(xx - 2, height - border - padbottom - 1, 5, 1);
878 dc.setForeground(backColor);
879 dc.fillRectangle(xx - 2, border, 5, height - (border << 1));
904 FXint rr = width - border - padright;
905 FXint ll = border + padleft;
913 if (options & TEXTFIELD_PASSWD) {
920 if (options & JUSTIFY_RIGHT) {
923 }
else if (
shift < 0) {
925 }
else if (
shift > tw - ww) {
928 }
else if (options & JUSTIFY_LEFT) {
931 }
else if (
shift > 0) {
933 }
else if (
shift < ww - tw) {
939 }
else if (
shift > tw / 2 - ww / 2) {
940 shift = tw / 2 - ww / 2;
941 }
else if (
shift < (ww - ww / 2) - tw / 2) {
942 shift = (ww - ww / 2) - tw / 2;
952 flags &= ~(FXuint)FLAG_DIRTY;
958 FXint rr = width - border - padright;
959 FXint ll = border + padleft;
961 FXint oldshift =
shift;
967 if (options & JUSTIFY_RIGHT) {
968 if (options & TEXTFIELD_PASSWD) {
973 if (
shift - xx > 0) {
975 }
else if (
shift - xx < -ww) {
978 }
else if (options & JUSTIFY_LEFT) {
979 if (options & TEXTFIELD_PASSWD) {
984 if (
shift + xx < 0) {
986 }
else if (
shift + xx >= ww) {
990 if (options & TEXTFIELD_PASSWD) {
995 if (
shift + ww / 2 + xx < 0) {
996 shift = -ww / 2 - xx;
997 }
else if (
shift + ww / 2 + xx >= ww) {
998 shift = ww - ww / 2 - xx;
1001 if (
shift != oldshift) {
1002 update(border, border, width - (border << 1), height - (border << 1));
1009 FXint rr = width - border - padright;
1010 FXint ll = border + padleft;
1011 FXint mm = (ll + rr) / 2;
1013 if (options & TEXTFIELD_PASSWD) {
1014 cw =
font->getTextWidth(
"*", 1);
1015 if (options & JUSTIFY_RIGHT) {
1017 }
else if (options & JUSTIFY_LEFT) {
1020 xx = mm - (cw *
contents.count()) / 2;
1023 pos =
contents.offset((x - xx + (cw >> 1)) / cw);
1025 if (options & JUSTIFY_RIGHT) {
1027 }
else if (options & JUSTIFY_LEFT) {
1035 if (x < (xx + (cw >> 1))) {
1053 FXint rr = width - border - padright;
1054 FXint ll = border + padleft;
1055 FXint mm = (ll + rr) / 2;
1057 FXASSERT(0 <= i && i <=
contents.length());
1058 if (options & JUSTIFY_RIGHT) {
1059 if (options & TEXTFIELD_PASSWD) {
1064 }
else if (options & JUSTIFY_LEFT) {
1065 if (options & TEXTFIELD_PASSWD) {
1066 pos = ll +
font->getTextWidth(
"*", 1) *
contents.index(i);
1071 if (options & TEXTFIELD_PASSWD) {
1083 if (0 <= pos && pos <=
contents.length()) {
1085 return border + padleft <= x && x <= width - border - padright;
1100 y +=
font->getFontAscent();
1101 dc.drawText(x, y, &
contents[fm], to - fm);
1107 FXint cw =
font->getTextWidth(
"*", 1);
1109 y +=
font->getFontAscent();
1111 for (i = fm; i < to; i =
contents.inc(i), x += cw) {
1112 dc.drawText(x, y,
"*", 1);
1119 FXint sx, ex, xx, yy, cw, hh, ww, si, ei, lx, rx, t;
1120 FXint rr = width - border - padright;
1121 FXint ll = border + padleft;
1122 FXint mm = (ll + rr) / 2;
1131 hh =
font->getFontHeight();
1133 if (options & JUSTIFY_TOP) {
1134 yy = padtop + border;
1135 }
else if (options & JUSTIFY_BOTTOM) {
1137 yy = height - padbottom - border - hh;
1140 yy = border + padtop + (height - padbottom - padtop - (border << 1) - hh) / 2;
1150 if (options & TEXTFIELD_PASSWD) {
1151 cw =
font->getTextWidth(
"*", 1);
1154 if (options & JUSTIFY_RIGHT) {
1155 xx =
shift + rr - ww;
1156 }
else if (options & JUSTIFY_LEFT) {
1161 xx =
shift + mm - ww / 2;
1178 if (rx - cw < width) {
1193 if (!hasSelection() || to <= si || ei <= fm) {
1212 dc.fillRectangle(sx, padtop + border, ex - sx, height - padtop - padbottom - (border << 1));
1216 dc.setForeground(baseColor);
1217 dc.fillRectangle(sx, padtop + border, ex - sx, height - padtop - padbottom - (border << 1));
1227 if (options & JUSTIFY_RIGHT) {
1228 xx =
shift + rr - ww;
1229 }
else if (options & JUSTIFY_LEFT) {
1234 xx =
shift + mm - ww / 2;
1255 if (rx - cw < width) {
1271 if (!hasSelection() || to <= si || ei <= fm) {
1290 dc.fillRectangle(sx, padtop + border, ex - sx, height - padtop - padbottom - (border << 1));
1294 dc.setForeground(baseColor);
1295 dc.fillRectangle(sx, padtop + border, ex - sx, height - padtop - padbottom - (border << 1));
1307 FXEvent* ev = (FXEvent*)ptr;
1308 FXDCWindow dc(
this, ev);
1310 drawFrame(dc, 0, 0, width, height);
1313 dc.setForeground(backColor);
1315 dc.setForeground(baseColor);
1318 dc.fillRectangle(border, border, width - (border << 1), height - (border << 1));
1320 dc.setClipRectangle(border, border, width - (border << 1), height - (border << 1));
1323 if (flags & FLAG_CARET) {
1330 dc.fillRectangle(xx, padtop + border, 1, height - padbottom - padtop - (border << 1));
1331 dc.fillRectangle(xx - 2, padtop + border, 5, 1);
1332 dc.fillRectangle(xx - 2, height - border - padbottom - 1, 5, 1);
1377 return w < 128 && strchr(delimiters, w);
1386 FXASSERT(0 <= pos && pos <=
contents.length());
1399 if ((pos == pp) && 0 <= (p =
contents.dec(pp))) {
1412 FXASSERT(0 <= pos && pos <=
contents.length());
1425 if ((pos == pp) && pp <
contents.length()) {
1436 FXASSERT(0 <= pos && pos <=
contents.length());
1456 FXASSERT(0 <= pos && pos <=
contents.length());
1538 if (hasSelection()) {
1539 FXDragType types[4];
1540 types[0] = stringType;
1541 types[1] = textType;
1542 types[2] = utf8Type;
1543 types[3] = utf16Type;
1544 if (acquireClipboard(types, 4)) {
1550 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_DELETE_SEL), NULL);
1562 if (hasSelection()) {
1563 FXDragType types[4];
1564 types[0] = stringType;
1565 types[1] = textType;
1566 types[2] = utf8Type;
1567 types[3] = utf16Type;
1568 if (acquireClipboard(types, 4)) {
1586 if (hasSelection()) {
1587 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_DELETE_SEL), NULL);
1591 if (getDNDData(FROM_CLIPBOARD, utf8Type,
string)) {
1592 FXTRACE((100,
"Paste UTF8\n"));
1593 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_INSERT_STRING), (
void*)
string.text());
1598 if (getDNDData(FROM_CLIPBOARD, utf16Type,
string)) {
1599 FXUTF16LECodec unicode;
1600 FXTRACE((100,
"Paste UTF16\n"));
1601 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_INSERT_STRING), (
void*)unicode.mb2utf(
string).text());
1606 if (getDNDData(FROM_CLIPBOARD, stringType,
string)) {
1608 FXTRACE((100,
"Paste ASCII\n"));
1609 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_INSERT_STRING), (
void*)ascii.mb2utf(
string).text());
1625 if (getDNDData(FROM_SELECTION, utf8Type,
string)) {
1626 FXTRACE((100,
"Paste UTF8\n"));
1627 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_INSERT_STRING), (
void*)
string.text());
1632 if (getDNDData(FROM_SELECTION, utf16Type,
string)) {
1633 FXUTF16LECodec unicode;
1634 FXTRACE((100,
"Paste UTF16\n"));
1635 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_INSERT_STRING), (
void*)unicode.mb2utf(
string).text());
1640 if (getDNDData(FROM_SELECTION, stringType,
string)) {
1642 FXTRACE((100,
"Paste ASCII\n"));
1643 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_INSERT_STRING), (
void*)ascii.mb2utf(
string).text());
1656 if (!hasSelection()) {
1667 flags |= FLAG_CHANGED;
1669 target->tryHandle(
this, FXSEL(SEL_CHANGED, message), (
void*)
contents.text());
1687 flags |= FLAG_CHANGED;
1689 target->tryHandle(
this, FXSEL(SEL_CHANGED, message), (
void*)
contents.text());
1702 FXint len = (int)strlen((FXchar*)ptr);
1705 if (hasSelection()) {
1709 tentative.replace(reppos, replen, (FXchar*)ptr, len);
1710 if (handle(
this, FXSEL(SEL_VERIFY, 0), (
void*)tentative.text())) {
1722 update(border, border, width - (border << 1), height - (border << 1));
1723 flags |= FLAG_CHANGED;
1725 target->tryHandle(
this, FXSEL(SEL_CHANGED, message), (
void*)
contents.text());
1738 FXint len = (int)strlen((FXchar*)ptr);
1741 if (hasSelection()) {
1745 tentative.replace(reppos, replen, (FXchar*)ptr, len);
1746 if (handle(
this, FXSEL(SEL_VERIFY, 0), (
void*)tentative.text())) {
1758 update(border, border, width - (border << 1), height - (border << 1));
1759 flags |= FLAG_CHANGED;
1761 target->tryHandle(
this, FXSEL(SEL_CHANGED, message), (
void*)
contents.text());
1779 update(border, border, width - (border << 1), height - (border << 1));
1780 flags |= FLAG_CHANGED;
1782 target->tryHandle(
this, FXSEL(SEL_CHANGED, message), (
void*)
contents.text());
1799 update(border, border, width - (border << 1), height - (border << 1));
1800 flags |= FLAG_CHANGED;
1802 target->tryHandle(
this, FXSEL(SEL_CHANGED, message), (
void*)
contents.text());
1813 FXchar* p = (FXchar*)ptr;
1816 if (options & TEXTFIELD_LIMITED) {
1817 if ((FXint)wcslen(p) >
columns) {
1823 if (options & TEXTFIELD_INTEGER) {
1824 while (Ascii::isSpace(*p)) {
1827 if (*p ==
'-' || *p ==
'+') {
1830 while (Ascii::isDigit(*p)) {
1833 while (Ascii::isSpace(*p)) {
1842 if (options & TEXTFIELD_REAL) {
1843 while (Ascii::isSpace(*p)) {
1846 if (*p ==
'-' || *p ==
'+') {
1849 while (Ascii::isDigit(*p)) {
1855 while (Ascii::isDigit(*p)) {
1858 if (*p ==
'E' || *p ==
'e') {
1860 if (*p ==
'-' || *p ==
'+') {
1863 while (Ascii::isDigit(*p)) {
1867 while (Ascii::isSpace(*p)) {
1876 if (target && target->tryHandle(
this, FXSEL(SEL_VERIFY, message), ptr)) {
1887 FXEvent*
event = (FXEvent*)ptr;
1890 FXTRACE((200,
"%s::onKeyPress keysym = 0x%04x state = %04x\n", getClassName(), event->code, event->state));
1891 if (target && target->tryHandle(
this, FXSEL(SEL_KEYPRESS, message), ptr)) {
1894 flags &= ~FLAG_UPDATE;
1895 switch (event->code) {
1898 if (!(event->state & SHIFTMASK)) {
1899 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_DESELECT_ALL), NULL);
1901 if (event->state & CONTROLMASK) {
1902 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_CURSOR_WORD_RIGHT), NULL);
1904 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_CURSOR_RIGHT), NULL);
1906 if (event->state & SHIFTMASK) {
1907 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_EXTEND), NULL);
1909 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_MARK), NULL);
1914 if (!(event->state & SHIFTMASK)) {
1915 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_DESELECT_ALL), NULL);
1917 if (event->state & CONTROLMASK) {
1918 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_CURSOR_WORD_LEFT), NULL);
1920 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_CURSOR_LEFT), NULL);
1922 if (event->state & SHIFTMASK) {
1923 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_EXTEND), NULL);
1925 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_MARK), NULL);
1930 if (!(event->state & SHIFTMASK)) {
1931 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_DESELECT_ALL), NULL);
1933 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_CURSOR_HOME), NULL);
1934 if (event->state & SHIFTMASK) {
1935 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_EXTEND), NULL);
1937 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_MARK), NULL);
1942 if (!(event->state & SHIFTMASK)) {
1943 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_DESELECT_ALL), NULL);
1945 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_CURSOR_END), NULL);
1946 if (event->state & SHIFTMASK) {
1947 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_EXTEND), NULL);
1949 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_MARK), NULL);
1954 if (event->state & CONTROLMASK) {
1955 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_COPY_SEL), NULL);
1956 }
else if (event->state & SHIFTMASK) {
1957 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_PASTE_SEL), NULL);
1959 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_TOGGLE_OVERSTRIKE), NULL);
1964 if (hasSelection()) {
1965 if (event->state & SHIFTMASK) {
1966 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_CUT_SEL), NULL);
1968 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_DELETE_SEL), NULL);
1971 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_DELETE), NULL);
1975 if (hasSelection()) {
1976 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_DELETE_SEL), NULL);
1978 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_BACKSPACE), NULL);
1984 flags |= FLAG_UPDATE;
1985 flags &= ~FLAG_CHANGED;
1987 target->tryHandle(
this, FXSEL(SEL_COMMAND, message), (
void*)
contents.text());
1994 if (!(event->state & CONTROLMASK)) {
1997 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_SELECT_ALL), NULL);
2000 if (!(event->state & CONTROLMASK)) {
2005 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_CUT_SEL), NULL);
2008 if (!(event->state & CONTROLMASK)) {
2013 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_COPY_SEL), NULL);
2016 if (!(event->state & CONTROLMASK)) {
2021 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_PASTE_SEL), NULL);
2026 if ((event->state & (CONTROLMASK | ALTMASK)) || ((FXuchar)event->text[0] < 32)) {
2030 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_OVERST_STRING), (
void*)event->text.text());
2032 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_INSERT_STRING), (
void*)event->text.text());
2042 FXEvent*
event = (FXEvent*)ptr;
2044 FXTRACE((200,
"%s::onKeyRelease keysym = 0x%04x state = %04x\n", getClassName(), ((FXEvent*)ptr)->code, ((FXEvent*)ptr)->state));
2045 if (target && target->tryHandle(
this, FXSEL(SEL_KEYRELEASE, message), ptr)) {
2048 switch (event->code) {
2071 if (event->state & CONTROLMASK) {
2076 if ((event->state & (CONTROLMASK | ALTMASK)) || ((FXuchar)event->text[0] < 32)) {
2088 if (hasSelection()) {
2090 update(border, border, width - (border << 1), height - (border << 1));
2117 FXDragType types[4];
2124 types[0] = stringType;
2125 types[1] = textType;
2126 types[2] = utf8Type;
2127 types[3] = utf16Type;
2128 if (!hasSelection()) {
2129 acquireSelection(types, 4);
2132 if (hasSelection()) {
2137 update(border, border, width - (border << 1), height - (border << 1));
2153 if (notify && target) {
2154 target->tryHandle(
this, FXSEL(SEL_COMMAND, message), (
void*)
contents.text());
2229 return (options & TEXTFIELD_READONLY) == 0;
2237 options &= ~TEXTFIELD_READONLY;
2239 options |= TEXTFIELD_READONLY;
2247 return (options & TEXTFIELD_OVERSTRIKE) != 0;
2255 options |= TEXTFIELD_OVERSTRIKE;
2257 options &= ~TEXTFIELD_OVERSTRIKE;
2264 FXuint opts = (options & ~TEXTFIELD_MASK) | (style &
TEXTFIELD_MASK);
2265 if (options != opts) {
2284 FXuint opts = (options & ~JUSTIFY_MASK) | (style &
JUSTIFY_MASK);
2285 if (options != opts) {
2304 FXFrame::save(store);
2320 FXFrame::load(store);
2334 flags |= FLAG_ENABLED;
2335 font = (FXFont*) - 1L;
static FXbool isdelimiter(const FXchar *delimiters, FXwchar w)
FXDEFMAP(MFXTextFieldIcon) MFXTextFieldIconMap[]
FXString clipped
Clipped text.
FXint cursor
Cursor position.
FXString contents
Edited text.
long onCmdOverstString(FXObject *, FXSelector, void *)
virtual void save(FXStream &store) const
Save text field to a stream.
virtual void disable()
Disable text field.
FXint coord(FXint i) const
coordinates
const FXchar * delimiters
Set of delimiters.
long onCmdSelectAll(FXObject *, FXSelector, void *)
long onCmdGetStringValue(FXObject *, FXSelector, void *)
void setCursorColor(FXColor clr)
Changes the cursor color.
void setSelTextColor(FXColor clr)
Change selected text color.
virtual void setFocus()
Move the focus to this window.
void setOverstrike(FXbool over=TRUE)
Set overstrike mode.
long onLeftBtnRelease(FXObject *, FXSelector, void *)
long onCmdGetRealValue(FXObject *, FXSelector, void *)
long onCmdGetHelp(FXObject *, FXSelector, void *)
long onBlink(FXObject *, FXSelector, void *)
long onCmdCursorHome(FXObject *, FXSelector, void *)
long onCmdCursorWordStart(FXObject *, FXSelector, void *)
const FXString & getTipText() const
Get the tool tip message for this text field.
long onKeyPress(FXObject *, FXSelector, void *)
long onFocusIn(FXObject *, FXSelector, void *)
virtual void killFocus()
Remove the focus from this window.
long onCmdSetTip(FXObject *, FXSelector, void *)
FXint wordStart(FXint pos) const
word start
long onCmdToggleOverstrike(FXObject *, FXSelector, void *)
void drawPWDTextFragment(FXDCWindow &dc, FXint x, FXint y, FXint fm, FXint to)
draw password text fragment
FXint columns
Number of columns visible.
virtual void enable()
Enable text field.
long onClipboardGained(FXObject *, FXSelector, void *)
long onLeftBtnPress(FXObject *, FXSelector, void *)
long onFocusOut(FXObject *, FXSelector, void *)
virtual FXint getDefaultWidth()
Return default width.
long onAutoScroll(FXObject *, FXSelector, void *)
MFXTextFieldIcon()
FOX need this.
FXint anchor
Anchor position.
void drawTextFragment(FXDCWindow &dc, FXint x, FXint y, FXint fm, FXint to)
draw text fragment
FXbool killSelection()
Unselect the text.
long onCmdPasteSel(FXObject *, FXSelector, void *)
long onQueryTip(FXObject *, FXSelector, void *)
FXColor selbackColor
Selected background color.
long onCmdCopySel(FXObject *, FXSelector, void *)
void makePositionVisible(FXint pos)
Scroll text to make the given position visible.
void setSelBackColor(FXColor clr)
Change selected background color.
FXColor textColor
Text color.
long onUpdToggleOverstrike(FXObject *, FXSelector, void *)
long onVerify(FXObject *, FXSelector, void *)
FXint leftWord(FXint pos) const
left word
long onCmdCursorLeft(FXObject *, FXSelector, void *)
long onCmdExtend(FXObject *, FXSelector, void *)
void drawTextRange(FXDCWindow &dc, FXint fm, FXint to)
draw text range
FXbool setSelection(FXint pos, FXint len)
Select len characters starting at given position pos.
long onMiddleBtnRelease(FXObject *, FXSelector, void *)
long onCmdCursorWordEnd(FXObject *, FXSelector, void *)
void drawCursor(FXuint state)
draw cursor
void setAnchorPos(FXint pos)
Change anchor position.
long onKeyRelease(FXObject *, FXSelector, void *)
long onSelectionRequest(FXObject *, FXSelector, void *ptr)
long onCmdDelete(FXObject *, FXSelector, void *)
long onCmdDeleteSel(FXObject *, FXSelector, void *)
long onClipboardLost(FXObject *, FXSelector, void *)
long onCmdSetRealValue(FXObject *, FXSelector, void *)
long onCmdCursorEnd(FXObject *, FXSelector, void *)
FXColor cursorColor
Color of the Cursor.
FXColor seltextColor
Selected text color.
virtual bool canFocus() const
Yes, text field may receive focus.
long onCmdSetValue(FXObject *, FXSelector, void *)
void setCursorPos(FXint pos)
Set cursor position.
virtual void load(FXStream &store)
Load text field from a stream.
void setFont(FXFont *fnt)
Set the text font.
long onUpdate(FXObject *, FXSelector, void *)
FXbool extendSelection(FXint pos)
Extend the selection from the anchor to the given position.
FXString getText() const
Get the text for this label.
long onUpdSelectAll(FXObject *, FXSelector, void *)
FXint index(FXint x) const
index
long onCmdPasteMiddle(FXObject *, FXSelector, void *)
long onCmdCursorWordLeft(FXObject *, FXSelector, void *)
FXString help
Help string.
void setEditable(FXbool edit=TRUE)
Set editable mode.
long onCmdSetStringValue(FXObject *, FXSelector, void *)
long onMotion(FXObject *, FXSelector, void *)
virtual FXint getDefaultHeight()
Return default height.
long onCmdCutSel(FXObject *, FXSelector, void *)
long onFocusSelf(FXObject *, FXSelector, void *)
void setJustify(FXuint mode)
Change text justification mode.
FXuint getTextStyle() const
Return text style.
virtual ~MFXTextFieldIcon()
Destructor.
long onSelectionGained(FXObject *, FXSelector, void *)
long onCmdDeselectAll(FXObject *, FXSelector, void *)
FXbool isPosVisible(FXint pos) const
Return TRUE if position is fully visible.
long onUpdToggleEditable(FXObject *, FXSelector, void *)
FXbool selectAll()
Select all text.
void setNumColumns(FXint cols)
Change the default width of the text field.
FXint rightWord(FXint pos) const
right word
long onCmdGetTip(FXObject *, FXSelector, void *)
long onClipboardRequest(FXObject *, FXSelector, void *)
void setTextColor(FXColor clr)
Change text color.
long onSelectionLost(FXObject *, FXSelector, void *)
long onCmdToggleEditable(FXObject *, FXSelector, void *)
long onCmdSetHelp(FXObject *, FXSelector, void *)
long onCmdInsertString(FXObject *, FXSelector, void *)
long onPaint(FXObject *, FXSelector, void *)
fox callbacks
long onCmdDeleteAll(FXObject *, FXSelector, void *)
const FXString & getHelpText() const
Get the status line help text for this label.
long onUpdHaveSelection(FXObject *, FXSelector, void *)
void setHelpText(const FXString &text)
Set the status line help text for this label.
FXbool isEditable() const
Return TRUE if text field may be edited.
long onQueryHelp(FXObject *, FXSelector, void *)
void setIcon(FXIcon *ic)
Change the icon.
long onCmdSetIntValue(FXObject *, FXSelector, void *)
void setTextStyle(FXuint style)
Change text style.
long onCmdCursorRight(FXObject *, FXSelector, void *)
void setTipText(const FXString &text)
Set the tool tip message for this text field.
FXint wordEnd(FXint pos) const
word end
long onMiddleBtnPress(FXObject *, FXSelector, void *)
virtual void create()
Create server-side resources.
virtual void layout()
Perform layout.
FXbool isPosSelected(FXint pos) const
Return TRUE if position pos is selected.
void setText(const FXString &text, FXbool notify=FALSE)
Change the text and move cursor to end.
long onCmdGetIntValue(FXObject *, FXSelector, void *)
long onCmdBackspace(FXObject *, FXSelector, void *)
FXbool isOverstrike() const
Return TRUE if overstrike mode in effect.
long onCmdCursorWordRight(FXObject *, FXSelector, void *)
FXuint getJustify() const
Return text justification mode.
long onCmdMark(FXObject *, FXSelector, void *)