30#include <FX88591Codec.h>
31#include <FX88591Codec.h>
32#include <FXCP1252Codec.h>
33#include <FXUTF16Codec.h>
40#define JUSTIFY_MASK (JUSTIFY_HZ_APART|JUSTIFY_VT_APART)
41#define TEXTFIELD_MASK (TEXTFIELD_PASSWD|TEXTFIELD_INTEGER|TEXTFIELD_REAL|TEXTFIELD_READONLY|TEXTFIELD_ENTER_ONLY|TEXTFIELD_LIMITED|TEXTFIELD_OVERSTRIKE|TEXTFIELD_AUTOHIDE|TEXTFIELD_AUTOGRAY)
78 FXMAPFUNC(SEL_UPDATE, FXTextField::ID_PASTE_SEL, MFXTextFieldIcon::onUpdYes),
119FXIMPLEMENT(
MFXTextFieldIcon, FXFrame, MFXTextFieldIconMap, ARRAYNUMBER(MFXTextFieldIconMap))
126 FXuint opts, FXint x, FXint y, FXint w, FXint h, FXint pl, FXint pr, FXint pt, FXint pb) :
127 FXFrame(p, opts, x, y, w, h, pl, pr, pt, pb),
132 flags |= FLAG_ENABLED;
135 if (!(options & JUSTIFY_RIGHT)) {
136 options |= JUSTIFY_LEFT;
138 defaultCursor = getApp()->getDefaultCursor(DEF_TEXT_CURSOR);
139 dragCursor = getApp()->getDefaultCursor(DEF_TEXT_CURSOR);
140 font = getApp()->getNormalFont();
141 backColor = getApp()->getBackColor();
142 textColor = getApp()->getForeColor();
143 selbackColor = getApp()->getSelbackColor();
144 seltextColor = getApp()->getSelforeColor();
145 cursorColor = getApp()->getForeColor();
151 getApp()->removeTimeout(
this, FXTextField::ID_BLINK);
152 getApp()->removeTimeout(
this, ID_AUTOSCROLL);
153 font = (FXFont*) - 1L;
161 textType = getApp()->registerDragType(textTypeName);
164 utf8Type = getApp()->registerDragType(utf8TypeName);
167 utf16Type = getApp()->registerDragType(utf16TypeName);
176 fxerror(
"%s::setFont: NULL font specified.\n", getClassName());
188 if (!(flags & FLAG_ENABLED)) {
197 if (flags & FLAG_ENABLED) {
206 return padleft + padright + (border << 1) +
columns *
font->getTextWidth(
"8", 1);
213 return padtop + padbottom + (border << 1) +
font->getFontHeight();
219 if (!FXFrame::onUpdate(sender, sel, ptr)) {
220 if (options & TEXTFIELD_AUTOHIDE) {
226 if (options & TEXTFIELD_AUTOGRAY) {
236 FXFrame::onSelectionGained(sender, sel, ptr);
244 FXFrame::onSelectionLost(sender, sel, ptr);
252 FXEvent*
event = (FXEvent*)ptr;
262 if (FXFrame::onSelectionRequest(sender, sel, ptr)) {
267 if (event->target == stringType || event->target == textType || event->target == utf8Type || event->target == utf16Type) {
282 if (options & TEXTFIELD_PASSWD) {
283 string.assign(
'*',
string.count());
287 if (event->target == utf8Type) {
288 FXTRACE((100,
"Request UTF8\n"));
289 setDNDData(FROM_SELECTION, event->target,
string);
294 if (event->target == stringType || event->target == textType) {
296 FXTRACE((100,
"Request ASCII\n"));
297 setDNDData(FROM_SELECTION, event->target, ascii.utf2mb(
string));
302 if (event->target == utf16Type) {
303 FXUTF16LECodec unicode;
304 FXTRACE((100,
"Request UTF16\n"));
305 setDNDData(FROM_SELECTION, event->target, unicode.utf2mb(
string));
315 FXFrame::onClipboardGained(sender, sel, ptr);
322 FXFrame::onClipboardLost(sender, sel, ptr);
331 FXEvent*
event = (FXEvent*)ptr;
335 if (FXFrame::onClipboardRequest(sender, sel, ptr)) {
340 if (event->target == stringType || event->target == textType || event->target == utf8Type || event->target == utf16Type) {
346 if (options & TEXTFIELD_PASSWD) {
347 string.assign(
'*',
string.count());
351 if (event->target == utf8Type) {
352 FXTRACE((100,
"Request UTF8\n"));
353 setDNDData(FROM_CLIPBOARD, event->target,
string);
358 if (event->target == stringType || event->target == textType) {
360 FXTRACE((100,
"Request ASCII\n"));
361 setDNDData(FROM_CLIPBOARD, event->target, ascii.utf2mb(
string));
366 if (event->target == utf16Type) {
367 FXUTF16LECodec unicode;
368 FXTRACE((100,
"Request UTF16\n"));
369 setDNDData(FROM_CLIPBOARD, event->target, unicode.utf2mb(
string));
380 getApp()->addTimeout(
this, FXTextField::ID_BLINK, getApp()->getBlinkSpeed());
387 FXFrame::onFocusIn(sender, sel, ptr);
389 getApp()->addTimeout(
this, FXTextField::ID_BLINK, getApp()->getBlinkSpeed());
392 if (hasSelection()) {
393 update(border, border, width - (border << 1), height - (border << 1));
401 FXFrame::onFocusOut(sender, sel, ptr);
402 getApp()->removeTimeout(
this, FXTextField::ID_BLINK);
404 if (hasSelection()) {
405 update(border, border, width - (border << 1), height - (border << 1));
413 if (FXFrame::onFocusSelf(sender, sel, ptr)) {
414 FXEvent*
event = (FXEvent*)ptr;
415 if (event->type == SEL_KEYPRESS || event->type == SEL_KEYRELEASE) {
416 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_SELECT_ALL), NULL);
434 flags &= ~FLAG_UPDATE;
435 if (getApp()->hasInputMethod()) {
436 createComposeContext();
443 FXFrame::killFocus();
445 flags |= FLAG_UPDATE;
446 if (flags & FLAG_CHANGED) {
447 flags &= ~FLAG_CHANGED;
448 if (!(options & TEXTFIELD_ENTER_ONLY)) {
450 target->tryHandle(
this, FXSEL(SEL_COMMAND, message), (
void*)
contents.text());
454 if (getApp()->hasInputMethod()) {
455 destroyComposeContext();
490 if (FXWindow::onQueryTip(sender, sel, ptr)) {
493 if ((flags & FLAG_TIP) && !
tip.empty()) {
494 sender->handle(
this, FXSEL(SEL_COMMAND, ID_SETSTRINGVALUE), (
void*)&
tip);
503 if (FXWindow::onQueryHelp(sender, sel, ptr)) {
506 if ((flags & FLAG_HELP) && !
help.empty()) {
507 sender->handle(
this, FXSEL(SEL_COMMAND, ID_SETSTRINGVALUE), (
void*)&
help);
523 setText(FXStringVal(*((FXint*)ptr)));
530 setText(FXStringVal(*((FXdouble*)ptr)));
544 *((FXint*)ptr) = FXIntVal(
contents);
551 *((FXdouble*)ptr) = FXDoubleVal(
contents);
565 FXEvent* ev = (FXEvent*)ptr;
567 handle(
this, FXSEL(SEL_FOCUS_SELF, 0), ptr);
570 if (target && target->tryHandle(
this, FXSEL(SEL_LEFTBUTTONPRESS, message), ptr)) {
573 flags &= ~FLAG_UPDATE;
574 if (ev->click_count == 1) {
576 if (ev->state & SHIFTMASK) {
583 flags |= FLAG_PRESSED;
600 flags &= ~FLAG_PRESSED;
602 target->tryHandle(
this, FXSEL(SEL_LEFTBUTTONRELEASE, message), ptr);
612 FXEvent* ev = (FXEvent*)ptr;
614 handle(
this, FXSEL(SEL_FOCUS_SELF, 0), ptr);
617 if (target && target->tryHandle(
this, FXSEL(SEL_MIDDLEBUTTONPRESS, message), ptr)) {
623 update(border, border, width - (border << 1), height - (border << 1));
624 flags &= ~FLAG_UPDATE;
635 if (target && target->tryHandle(
this, FXSEL(SEL_MIDDLEBUTTONRELEASE, message), ptr)) {
638 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_PASTE_MIDDLE), NULL);
646 FXEvent*
event = (FXEvent*)ptr;
648 if (flags & FLAG_PRESSED) {
649 if (event->win_x < (border + padleft) || (width - border - padright) < event->win_x) {
650 if (!getApp()->hasTimeout(
this, ID_AUTOSCROLL)) {
651 getApp()->addTimeout(
this, ID_AUTOSCROLL, getApp()->getScrollSpeed(), event);
654 getApp()->removeTimeout(
this, ID_AUTOSCROLL);
655 t =
index(event->win_x);
670 FXEvent*
event = (FXEvent*)ptr;
671 if (flags & FLAG_PRESSED) {
673 FXint ll = border + padleft;
674 FXint rr = width - border - padright;
678 if (options & TEXTFIELD_PASSWD) {
685 if (options & JUSTIFY_RIGHT) {
688 if (event->win_x < ll) {
690 shift += ll -
event->win_x;
691 if (ww > tw -
shift) {
694 getApp()->addTimeout(
this, ID_AUTOSCROLL, getApp()->getScrollSpeed(), event);
697 newcursor =
index(ll);
701 if (rr < event->win_x) {
703 shift += rr -
event->win_x;
707 getApp()->addTimeout(
this, ID_AUTOSCROLL, getApp()->getScrollSpeed(), event);
710 newcursor =
index(rr);
715 else if (options & JUSTIFY_LEFT) {
718 if (event->win_x < ll) {
720 shift += ll -
event->win_x;
724 getApp()->addTimeout(
this, ID_AUTOSCROLL, getApp()->getScrollSpeed(), event);
727 newcursor =
index(ll);
731 if (rr < event->win_x) {
733 shift += rr -
event->win_x;
734 if (
shift + tw < ww) {
737 getApp()->addTimeout(
this, ID_AUTOSCROLL, getApp()->getScrollSpeed(), event);
740 newcursor =
index(rr);
744 if (event->win_x < ll) {
746 shift += ll -
event->win_x;
747 if (
shift > tw / 2 - ww / 2) {
748 shift = tw / 2 - ww / 2;
750 getApp()->addTimeout(
this, ID_AUTOSCROLL, getApp()->getScrollSpeed(), event);
753 newcursor =
index(ll);
756 if (rr < event->win_x) {
758 shift += rr -
event->win_x;
759 if (
shift < (ww - ww / 2) - tw / 2) {
760 shift = (ww - ww / 2) - tw / 2;
762 getApp()->addTimeout(
this, ID_AUTOSCROLL, getApp()->getScrollSpeed(), event);
765 newcursor =
index(rr);
769 if (newcursor !=
cursor) {
788 sender->handle(
this,
isOverstrike() ? FXSEL(SEL_COMMAND, ID_CHECK) : FXSEL(SEL_COMMAND, ID_UNCHECK), NULL);
789 sender->handle(
this, FXSEL(SEL_COMMAND, ID_SHOW), NULL);
790 sender->handle(
this, FXSEL(SEL_COMMAND, ID_ENABLE), NULL);
804 sender->handle(
this,
isEditable() ? FXSEL(SEL_COMMAND, ID_CHECK) : FXSEL(SEL_COMMAND, ID_UNCHECK), NULL);
805 sender->handle(
this, FXSEL(SEL_COMMAND, ID_SHOW), NULL);
806 sender->handle(
this, FXSEL(SEL_COMMAND, ID_ENABLE), NULL);
813 sender->handle(
this, hasSelection() ? FXSEL(SEL_COMMAND, ID_ENABLE) : FXSEL(SEL_COMMAND, ID_DISABLE), ptr);
820 sender->handle(
this,
contents.empty() ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE), ptr);
846 FXint cl, ch, xx, xlo, xhi;
847 if ((state ^ flags) & FLAG_CARET) {
858 xlo = FXMAX(xx - 2, border);
859 xhi = FXMIN(xx + 3, width - border);
861 dc.setClipRectangle(xlo, border, xhi - xlo, height - (border << 1));
863 if (state & FLAG_CARET) {
866 dc.fillRectangle(xx, padtop + border, 1, height - padbottom - padtop - (border << 1));
867 dc.fillRectangle(xx - 2, padtop + border, 5, 1);
868 dc.fillRectangle(xx - 2, height - border - padbottom - 1, 5, 1);
871 dc.setForeground(backColor);
872 dc.fillRectangle(xx - 2, border, 5, height - (border << 1));
897 FXint rr = width - border - padright;
898 FXint ll = border + padleft;
906 if (options & TEXTFIELD_PASSWD) {
913 if (options & JUSTIFY_RIGHT) {
916 }
else if (
shift < 0) {
918 }
else if (
shift > tw - ww) {
921 }
else if (options & JUSTIFY_LEFT) {
924 }
else if (
shift > 0) {
926 }
else if (
shift < ww - tw) {
932 }
else if (
shift > tw / 2 - ww / 2) {
933 shift = tw / 2 - ww / 2;
934 }
else if (
shift < (ww - ww / 2) - tw / 2) {
935 shift = (ww - ww / 2) - tw / 2;
945 flags &= ~(FXuint)FLAG_DIRTY;
951 FXint rr = width - border - padright;
952 FXint ll = border + padleft;
954 FXint oldshift =
shift;
960 if (options & JUSTIFY_RIGHT) {
961 if (options & TEXTFIELD_PASSWD) {
966 if (
shift - xx > 0) {
968 }
else if (
shift - xx < -ww) {
971 }
else if (options & JUSTIFY_LEFT) {
972 if (options & TEXTFIELD_PASSWD) {
977 if (
shift + xx < 0) {
979 }
else if (
shift + xx >= ww) {
983 if (options & TEXTFIELD_PASSWD) {
988 if (
shift + ww / 2 + xx < 0) {
989 shift = -ww / 2 - xx;
990 }
else if (
shift + ww / 2 + xx >= ww) {
991 shift = ww - ww / 2 - xx;
994 if (
shift != oldshift) {
995 update(border, border, width - (border << 1), height - (border << 1));
1002 FXint rr = width - border - padright;
1003 FXint ll = border + padleft;
1004 FXint mm = (ll + rr) / 2;
1006 if (options & TEXTFIELD_PASSWD) {
1007 cw =
font->getTextWidth(
"*", 1);
1008 if (options & JUSTIFY_RIGHT) {
1010 }
else if (options & JUSTIFY_LEFT) {
1013 xx = mm - (cw *
contents.count()) / 2;
1016 pos =
contents.offset((x - xx + (cw >> 1)) / cw);
1018 if (options & JUSTIFY_RIGHT) {
1020 }
else if (options & JUSTIFY_LEFT) {
1028 if (x < (xx + (cw >> 1))) {
1046 FXint rr = width - border - padright;
1047 FXint ll = border + padleft;
1048 FXint mm = (ll + rr) / 2;
1050 FXASSERT(0 <= i && i <=
contents.length());
1051 if (options & JUSTIFY_RIGHT) {
1052 if (options & TEXTFIELD_PASSWD) {
1057 }
else if (options & JUSTIFY_LEFT) {
1058 if (options & TEXTFIELD_PASSWD) {
1059 pos = ll +
font->getTextWidth(
"*", 1) *
contents.index(i);
1064 if (options & TEXTFIELD_PASSWD) {
1076 if (0 <= pos && pos <=
contents.length()) {
1078 return border + padleft <= x && x <= width - border - padright;
1093 y +=
font->getFontAscent();
1094 dc.drawText(x, y, &
contents[fm], to - fm);
1100 FXint cw =
font->getTextWidth(
"*", 1);
1102 y +=
font->getFontAscent();
1104 for (i = fm; i < to; i =
contents.inc(i), x += cw) {
1105 dc.drawText(x, y,
"*", 1);
1112 FXint sx, ex, xx, yy, cw, hh, ww, si, ei, lx, rx, t;
1113 FXint rr = width - border - padright;
1114 FXint ll = border + padleft;
1115 FXint mm = (ll + rr) / 2;
1124 hh =
font->getFontHeight();
1126 if (options & JUSTIFY_TOP) {
1127 yy = padtop + border;
1128 }
else if (options & JUSTIFY_BOTTOM) {
1130 yy = height - padbottom - border - hh;
1133 yy = border + padtop + (height - padbottom - padtop - (border << 1) - hh) / 2;
1143 if (options & TEXTFIELD_PASSWD) {
1144 cw =
font->getTextWidth(
"*", 1);
1147 if (options & JUSTIFY_RIGHT) {
1148 xx =
shift + rr - ww;
1149 }
else if (options & JUSTIFY_LEFT) {
1154 xx =
shift + mm - ww / 2;
1171 if (rx - cw < width) {
1186 if (!hasSelection() || to <= si || ei <= fm) {
1205 dc.fillRectangle(sx, padtop + border, ex - sx, height - padtop - padbottom - (border << 1));
1209 dc.setForeground(baseColor);
1210 dc.fillRectangle(sx, padtop + border, ex - sx, height - padtop - padbottom - (border << 1));
1220 if (options & JUSTIFY_RIGHT) {
1221 xx =
shift + rr - ww;
1222 }
else if (options & JUSTIFY_LEFT) {
1227 xx =
shift + mm - ww / 2;
1248 if (rx - cw < width) {
1264 if (!hasSelection() || to <= si || ei <= fm) {
1283 dc.fillRectangle(sx, padtop + border, ex - sx, height - padtop - padbottom - (border << 1));
1287 dc.setForeground(baseColor);
1288 dc.fillRectangle(sx, padtop + border, ex - sx, height - padtop - padbottom - (border << 1));
1300 FXEvent* ev = (FXEvent*)ptr;
1301 FXDCWindow dc(
this, ev);
1303 drawFrame(dc, 0, 0, width, height);
1306 dc.setForeground(backColor);
1308 dc.setForeground(baseColor);
1311 dc.fillRectangle(border, border, width - (border << 1), height - (border << 1));
1313 dc.setClipRectangle(border, border, width - (border << 1), height - (border << 1));
1316 if (flags & FLAG_CARET) {
1323 dc.fillRectangle(xx, padtop + border, 1, height - padbottom - padtop - (border << 1));
1324 dc.fillRectangle(xx - 2, padtop + border, 5, 1);
1325 dc.fillRectangle(xx - 2, height - border - padbottom - 1, 5, 1);
1370 return w < 128 && strchr(delimiters, w);
1379 FXASSERT(0 <= pos && pos <=
contents.length());
1392 if ((pos == pp) && 0 <= (p =
contents.dec(pp))) {
1405 FXASSERT(0 <= pos && pos <=
contents.length());
1418 if ((pos == pp) && pp <
contents.length()) {
1429 FXASSERT(0 <= pos && pos <=
contents.length());
1449 FXASSERT(0 <= pos && pos <=
contents.length());
1531 if (hasSelection()) {
1532 FXDragType types[4];
1533 types[0] = stringType;
1534 types[1] = textType;
1535 types[2] = utf8Type;
1536 types[3] = utf16Type;
1537 if (acquireClipboard(types, 4)) {
1543 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_DELETE_SEL), NULL);
1555 if (hasSelection()) {
1556 FXDragType types[4];
1557 types[0] = stringType;
1558 types[1] = textType;
1559 types[2] = utf8Type;
1560 types[3] = utf16Type;
1561 if (acquireClipboard(types, 4)) {
1579 if (hasSelection()) {
1580 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_DELETE_SEL), NULL);
1584 if (getDNDData(FROM_CLIPBOARD, utf8Type,
string)) {
1585 FXTRACE((100,
"Paste UTF8\n"));
1586 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_INSERT_STRING), (
void*)
string.text());
1591 if (getDNDData(FROM_CLIPBOARD, utf16Type,
string)) {
1592 FXUTF16LECodec unicode;
1593 FXTRACE((100,
"Paste UTF16\n"));
1594 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_INSERT_STRING), (
void*)unicode.mb2utf(
string).text());
1599 if (getDNDData(FROM_CLIPBOARD, stringType,
string)) {
1601 FXTRACE((100,
"Paste ASCII\n"));
1602 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_INSERT_STRING), (
void*)ascii.mb2utf(
string).text());
1618 if (getDNDData(FROM_SELECTION, utf8Type,
string)) {
1619 FXTRACE((100,
"Paste UTF8\n"));
1620 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_INSERT_STRING), (
void*)
string.text());
1625 if (getDNDData(FROM_SELECTION, utf16Type,
string)) {
1626 FXUTF16LECodec unicode;
1627 FXTRACE((100,
"Paste UTF16\n"));
1628 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_INSERT_STRING), (
void*)unicode.mb2utf(
string).text());
1633 if (getDNDData(FROM_SELECTION, stringType,
string)) {
1635 FXTRACE((100,
"Paste ASCII\n"));
1636 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_INSERT_STRING), (
void*)ascii.mb2utf(
string).text());
1649 if (!hasSelection()) {
1660 flags |= FLAG_CHANGED;
1662 target->tryHandle(
this, FXSEL(SEL_CHANGED, message), (
void*)
contents.text());
1680 flags |= FLAG_CHANGED;
1682 target->tryHandle(
this, FXSEL(SEL_CHANGED, message), (
void*)
contents.text());
1695 FXint len = (int)strlen((FXchar*)ptr);
1698 if (hasSelection()) {
1702 tentative.replace(reppos, replen, (FXchar*)ptr, len);
1703 if (handle(
this, FXSEL(SEL_VERIFY, 0), (
void*)tentative.text())) {
1715 update(border, border, width - (border << 1), height - (border << 1));
1716 flags |= FLAG_CHANGED;
1718 target->tryHandle(
this, FXSEL(SEL_CHANGED, message), (
void*)
contents.text());
1731 FXint len = (int)strlen((FXchar*)ptr);
1734 if (hasSelection()) {
1738 tentative.replace(reppos, replen, (FXchar*)ptr, len);
1739 if (handle(
this, FXSEL(SEL_VERIFY, 0), (
void*)tentative.text())) {
1751 update(border, border, width - (border << 1), height - (border << 1));
1752 flags |= FLAG_CHANGED;
1754 target->tryHandle(
this, FXSEL(SEL_CHANGED, message), (
void*)
contents.text());
1772 update(border, border, width - (border << 1), height - (border << 1));
1773 flags |= FLAG_CHANGED;
1775 target->tryHandle(
this, FXSEL(SEL_CHANGED, message), (
void*)
contents.text());
1792 update(border, border, width - (border << 1), height - (border << 1));
1793 flags |= FLAG_CHANGED;
1795 target->tryHandle(
this, FXSEL(SEL_CHANGED, message), (
void*)
contents.text());
1806 FXchar* p = (FXchar*)ptr;
1809 if (options & TEXTFIELD_LIMITED) {
1810 if ((FXint)wcslen(p) >
columns) {
1816 if (options & TEXTFIELD_INTEGER) {
1817 while (Ascii::isSpace(*p)) {
1820 if (*p ==
'-' || *p ==
'+') {
1823 while (Ascii::isDigit(*p)) {
1826 while (Ascii::isSpace(*p)) {
1835 if (options & TEXTFIELD_REAL) {
1836 while (Ascii::isSpace(*p)) {
1839 if (*p ==
'-' || *p ==
'+') {
1842 while (Ascii::isDigit(*p)) {
1848 while (Ascii::isDigit(*p)) {
1851 if (*p ==
'E' || *p ==
'e') {
1853 if (*p ==
'-' || *p ==
'+') {
1856 while (Ascii::isDigit(*p)) {
1860 while (Ascii::isSpace(*p)) {
1869 if (target && target->tryHandle(
this, FXSEL(SEL_VERIFY, message), ptr)) {
1880 FXEvent*
event = (FXEvent*)ptr;
1883 FXTRACE((200,
"%s::onKeyPress keysym = 0x%04x state = %04x\n", getClassName(), event->code, event->state));
1884 if (target && target->tryHandle(
this, FXSEL(SEL_KEYPRESS, message), ptr)) {
1887 flags &= ~FLAG_UPDATE;
1888 switch (event->code) {
1891 if (!(event->state & SHIFTMASK)) {
1892 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_DESELECT_ALL), NULL);
1894 if (event->state & CONTROLMASK) {
1895 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_CURSOR_WORD_RIGHT), NULL);
1897 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_CURSOR_RIGHT), NULL);
1899 if (event->state & SHIFTMASK) {
1900 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_EXTEND), NULL);
1902 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_MARK), NULL);
1907 if (!(event->state & SHIFTMASK)) {
1908 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_DESELECT_ALL), NULL);
1910 if (event->state & CONTROLMASK) {
1911 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_CURSOR_WORD_LEFT), NULL);
1913 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_CURSOR_LEFT), NULL);
1915 if (event->state & SHIFTMASK) {
1916 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_EXTEND), NULL);
1918 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_MARK), NULL);
1923 if (!(event->state & SHIFTMASK)) {
1924 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_DESELECT_ALL), NULL);
1926 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_CURSOR_HOME), NULL);
1927 if (event->state & SHIFTMASK) {
1928 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_EXTEND), NULL);
1930 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_MARK), NULL);
1935 if (!(event->state & SHIFTMASK)) {
1936 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_DESELECT_ALL), NULL);
1938 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_CURSOR_END), NULL);
1939 if (event->state & SHIFTMASK) {
1940 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_EXTEND), NULL);
1942 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_MARK), NULL);
1947 if (event->state & CONTROLMASK) {
1948 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_COPY_SEL), NULL);
1949 }
else if (event->state & SHIFTMASK) {
1950 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_PASTE_SEL), NULL);
1952 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_TOGGLE_OVERSTRIKE), NULL);
1957 if (hasSelection()) {
1958 if (event->state & SHIFTMASK) {
1959 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_CUT_SEL), NULL);
1961 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_DELETE_SEL), NULL);
1964 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_DELETE), NULL);
1968 if (hasSelection()) {
1969 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_DELETE_SEL), NULL);
1971 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_BACKSPACE), NULL);
1977 flags |= FLAG_UPDATE;
1978 flags &= ~FLAG_CHANGED;
1980 target->tryHandle(
this, FXSEL(SEL_COMMAND, message), (
void*)
contents.text());
1987 if (!(event->state & CONTROLMASK)) {
1990 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_SELECT_ALL), NULL);
1993 if (!(event->state & CONTROLMASK)) {
1998 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_CUT_SEL), NULL);
2001 if (!(event->state & CONTROLMASK)) {
2006 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_COPY_SEL), NULL);
2009 if (!(event->state & CONTROLMASK)) {
2014 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_PASTE_SEL), NULL);
2019 if ((event->state & (CONTROLMASK | ALTMASK)) || ((FXuchar)event->text[0] < 32)) {
2023 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_OVERST_STRING), (
void*)event->text.text());
2025 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_INSERT_STRING), (
void*)event->text.text());
2035 FXEvent*
event = (FXEvent*)ptr;
2037 FXTRACE((200,
"%s::onKeyRelease keysym = 0x%04x state = %04x\n", getClassName(), ((FXEvent*)ptr)->code, ((FXEvent*)ptr)->state));
2038 if (target && target->tryHandle(
this, FXSEL(SEL_KEYRELEASE, message), ptr)) {
2041 switch (event->code) {
2064 if (event->state & CONTROLMASK) {
2069 if ((event->state & (CONTROLMASK | ALTMASK)) || ((FXuchar)event->text[0] < 32)) {
2081 if (hasSelection()) {
2083 update(border, border, width - (border << 1), height - (border << 1));
2110 FXDragType types[4];
2117 types[0] = stringType;
2118 types[1] = textType;
2119 types[2] = utf8Type;
2120 types[3] = utf16Type;
2121 if (!hasSelection()) {
2122 acquireSelection(types, 4);
2125 if (hasSelection()) {
2130 update(border, border, width - (border << 1), height - (border << 1));
2146 if (notify && target) {
2147 target->tryHandle(
this, FXSEL(SEL_COMMAND, message), (
void*)
contents.text());
2222 return (options & TEXTFIELD_READONLY) == 0;
2230 options &= ~TEXTFIELD_READONLY;
2232 options |= TEXTFIELD_READONLY;
2240 return (options & TEXTFIELD_OVERSTRIKE) != 0;
2248 options |= TEXTFIELD_OVERSTRIKE;
2250 options &= ~TEXTFIELD_OVERSTRIKE;
2257 FXuint opts = (options & ~TEXTFIELD_MASK) | (style &
TEXTFIELD_MASK);
2258 if (options != opts) {
2277 FXuint opts = (options & ~JUSTIFY_MASK) | (style &
JUSTIFY_MASK);
2278 if (options != opts) {
2297 FXFrame::save(store);
2313 FXFrame::load(store);
2327 flags |= FLAG_ENABLED;
2328 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 *)