27#pragma warning(disable: 4266)
29#include <FX88591Codec.h>
30#include <FXUTF16Codec.h>
42#define JUSTIFY_MASK (JUSTIFY_HZ_APART|JUSTIFY_VT_APART)
43#define TEXTFIELD_MASK (TEXTFIELD_PASSWD|TEXTFIELD_INTEGER|TEXTFIELD_REAL|TEXTFIELD_READONLY|TEXTFIELD_ENTER_ONLY|TEXTFIELD_LIMITED|TEXTFIELD_OVERSTRIKE|TEXTFIELD_AUTOHIDE|TEXTFIELD_AUTOGRAY)
116 FXMAPFUNC(SEL_UPDATE, FXTextField::ID_PASTE_SEL, MFXTextFieldIcon::onUpdYes),
123FXIMPLEMENT(
MFXTextFieldIcon, FXFrame, MFXTextFieldIconMap, ARRAYNUMBER(MFXTextFieldIconMap))
130 FXuint opts, FXint x, FXint y, FXint w, FXint h, FXint pl, FXint pr, FXint pt, FXint pb) :
131 FXFrame(p, opts, x, y, w, h, pl, pr, pt, pb),
132 myStaticToolTip(staticToolTip) {
137 flags |= FLAG_ENABLED;
140 if (!(options & JUSTIFY_RIGHT)) {
141 options |= JUSTIFY_LEFT;
143 defaultCursor = getApp()->getDefaultCursor(DEF_TEXT_CURSOR);
144 dragCursor = getApp()->getDefaultCursor(DEF_TEXT_CURSOR);
145 myFont = getApp()->getNormalFont();
146 backColor = getApp()->getBackColor();
147 myTextColor = getApp()->getForeColor();
148 mySelectedBackgroundColor = getApp()->getSelbackColor();
149 mySelectedTextColor = getApp()->getSelforeColor();
150 myCursorColor = getApp()->getForeColor();
156 getApp()->removeTimeout(
this, FXTextField::ID_BLINK);
157 getApp()->removeTimeout(
this, ID_AUTOSCROLL);
166 textType = getApp()->registerDragType(textTypeName);
169 utf8Type = getApp()->registerDragType(utf8TypeName);
172 utf16Type = getApp()->registerDragType(utf16TypeName);
181 fxerror(
"%s::setFont: NULL font specified.\n", getClassName());
199 if (!(flags & FLAG_ENABLED)) {
208 if (flags & FLAG_ENABLED) {
224 return padtop + padbottom + (border << 1) +
myFont->getFontHeight();
230 if (!FXFrame::onUpdate(sender, sel, ptr)) {
231 if (options & TEXTFIELD_AUTOHIDE) {
237 if (options & TEXTFIELD_AUTOGRAY) {
247 FXFrame::onSelectionGained(sender, sel, ptr);
255 FXFrame::onSelectionLost(sender, sel, ptr);
263 FXEvent*
event = (FXEvent*)ptr;
273 if (FXFrame::onSelectionRequest(sender, sel, ptr)) {
278 if (event->target == stringType || event->target == textType || event->target == utf8Type || event->target == utf16Type) {
293 if (options & TEXTFIELD_PASSWD) {
294 string.assign(
'*',
string.count());
298 if (event->target == utf8Type) {
299 FXTRACE((100,
"Request UTF8\n"));
300 setDNDData(FROM_SELECTION, event->target,
string);
305 if (event->target == stringType || event->target == textType) {
307 FXTRACE((100,
"Request ASCII\n"));
308 setDNDData(FROM_SELECTION, event->target, ascii.utf2mb(
string));
313 if (event->target == utf16Type) {
314 FXUTF16LECodec unicode;
315 FXTRACE((100,
"Request UTF16\n"));
316 setDNDData(FROM_SELECTION, event->target, unicode.utf2mb(
string));
326 FXFrame::onClipboardGained(sender, sel, ptr);
333 FXFrame::onClipboardLost(sender, sel, ptr);
342 FXEvent*
event = (FXEvent*)ptr;
346 if (FXFrame::onClipboardRequest(sender, sel, ptr)) {
351 if (event->target == stringType || event->target == textType || event->target == utf8Type || event->target == utf16Type) {
357 if (options & TEXTFIELD_PASSWD) {
358 string.assign(
'*',
string.count());
362 if (event->target == utf8Type) {
363 FXTRACE((100,
"Request UTF8\n"));
364 setDNDData(FROM_CLIPBOARD, event->target,
string);
369 if (event->target == stringType || event->target == textType) {
371 FXTRACE((100,
"Request ASCII\n"));
372 setDNDData(FROM_CLIPBOARD, event->target, ascii.utf2mb(
string));
377 if (event->target == utf16Type) {
378 FXUTF16LECodec unicode;
379 FXTRACE((100,
"Request UTF16\n"));
380 setDNDData(FROM_CLIPBOARD, event->target, unicode.utf2mb(
string));
391 getApp()->addTimeout(
this, FXTextField::ID_BLINK, getApp()->getBlinkSpeed());
398 FXFrame::onFocusIn(sender, sel, ptr);
400 getApp()->addTimeout(
this, FXTextField::ID_BLINK, getApp()->getBlinkSpeed());
403 if (hasSelection()) {
404 update(border, border, width - (border << 1), height - (border << 1));
412 FXFrame::onFocusOut(sender, sel, ptr);
413 getApp()->removeTimeout(
this, FXTextField::ID_BLINK);
415 if (hasSelection()) {
416 update(border, border, width - (border << 1), height - (border << 1));
424 if (FXFrame::onFocusSelf(sender, sel, ptr)) {
425 FXEvent*
event = (FXEvent*)ptr;
426 if (event->type == SEL_KEYPRESS || event->type == SEL_KEYRELEASE) {
427 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_SELECT_ALL), NULL);
445 flags &= ~FLAG_UPDATE;
446 if (getApp()->hasInputMethod()) {
447 createComposeContext();
454 FXFrame::killFocus();
456 flags |= FLAG_UPDATE;
457 if (flags & FLAG_CHANGED) {
458 flags &= ~FLAG_CHANGED;
459 if (!(options & TEXTFIELD_ENTER_ONLY)) {
461 target->tryHandle(
this, FXSEL(SEL_COMMAND, message), (
void*)
contents.text());
465 if (getApp()->hasInputMethod()) {
466 destroyComposeContext();
501 if (FXWindow::onQueryTip(sender, sel, ptr)) {
505 sender->handle(
this, FXSEL(SEL_COMMAND, ID_SETSTRINGVALUE), (
void*)&
myTooltipText);
514 if (FXWindow::onQueryHelp(sender, sel, ptr)) {
517 if ((flags & FLAG_HELP) && !
myHelpText.empty()) {
518 sender->handle(
this, FXSEL(SEL_COMMAND, ID_SETSTRINGVALUE), (
void*)&
myHelpText);
534 setText(FXStringVal(*((FXint*)ptr)));
541 setText(FXStringVal(*((FXdouble*)ptr)));
555 *((FXint*)ptr) = FXIntVal(
contents);
562 *((FXdouble*)ptr) = FXDoubleVal(
contents);
576 FXEvent* ev = (FXEvent*)ptr;
578 handle(
this, FXSEL(SEL_FOCUS_SELF, 0), ptr);
581 if (target && target->tryHandle(
this, FXSEL(SEL_LEFTBUTTONPRESS, message), ptr)) {
584 flags &= ~FLAG_UPDATE;
585 if (ev->click_count == 1) {
587 if (ev->state & SHIFTMASK) {
594 flags |= FLAG_PRESSED;
611 flags &= ~FLAG_PRESSED;
613 target->tryHandle(
this, FXSEL(SEL_LEFTBUTTONRELEASE, message), ptr);
623 FXEvent* ev = (FXEvent*)ptr;
625 handle(
this, FXSEL(SEL_FOCUS_SELF, 0), ptr);
628 if (target && target->tryHandle(
this, FXSEL(SEL_MIDDLEBUTTONPRESS, message), ptr)) {
634 update(border, border, width - (border << 1), height - (border << 1));
635 flags &= ~FLAG_UPDATE;
646 if (target && target->tryHandle(
this, FXSEL(SEL_MIDDLEBUTTONRELEASE, message), ptr)) {
649 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_PASTE_MIDDLE), NULL);
661 FXEvent*
event = (FXEvent*)ptr;
663 if (flags & FLAG_PRESSED) {
664 if (event->win_x < (border + padleft) || (width - border - padright) < event->win_x) {
665 if (!getApp()->hasTimeout(
this, ID_AUTOSCROLL)) {
666 getApp()->addTimeout(
this, ID_AUTOSCROLL, getApp()->getScrollSpeed(), event);
669 getApp()->removeTimeout(
this, ID_AUTOSCROLL);
670 t =
index(event->win_x);
685 FXEvent*
event = (FXEvent*)ptr;
686 if (flags & FLAG_PRESSED) {
688 FXint ll = border + padleft;
689 FXint rr = width - border - padright;
693 if (options & TEXTFIELD_PASSWD) {
700 if (options & JUSTIFY_RIGHT) {
703 if (event->win_x < ll) {
709 getApp()->addTimeout(
this, ID_AUTOSCROLL, getApp()->getScrollSpeed(), event);
712 newcursor =
index(ll);
716 if (rr < event->win_x) {
722 getApp()->addTimeout(
this, ID_AUTOSCROLL, getApp()->getScrollSpeed(), event);
725 newcursor =
index(rr);
730 else if (options & JUSTIFY_LEFT) {
733 if (event->win_x < ll) {
739 getApp()->addTimeout(
this, ID_AUTOSCROLL, getApp()->getScrollSpeed(), event);
742 newcursor =
index(ll);
746 if (rr < event->win_x) {
752 getApp()->addTimeout(
this, ID_AUTOSCROLL, getApp()->getScrollSpeed(), event);
755 newcursor =
index(rr);
759 if (event->win_x < ll) {
765 getApp()->addTimeout(
this, ID_AUTOSCROLL, getApp()->getScrollSpeed(), event);
768 newcursor =
index(ll);
771 if (rr < event->win_x) {
777 getApp()->addTimeout(
this, ID_AUTOSCROLL, getApp()->getScrollSpeed(), event);
780 newcursor =
index(rr);
803 sender->handle(
this,
isOverstrike() ? FXSEL(SEL_COMMAND, ID_CHECK) : FXSEL(SEL_COMMAND, ID_UNCHECK), NULL);
804 sender->handle(
this, FXSEL(SEL_COMMAND, ID_SHOW), NULL);
805 sender->handle(
this, FXSEL(SEL_COMMAND, ID_ENABLE), NULL);
819 sender->handle(
this,
isEditable() ? FXSEL(SEL_COMMAND, ID_CHECK) : FXSEL(SEL_COMMAND, ID_UNCHECK), NULL);
820 sender->handle(
this, FXSEL(SEL_COMMAND, ID_SHOW), NULL);
821 sender->handle(
this, FXSEL(SEL_COMMAND, ID_ENABLE), NULL);
828 sender->handle(
this, hasSelection() ? FXSEL(SEL_COMMAND, ID_ENABLE) : FXSEL(SEL_COMMAND, ID_DISABLE), ptr);
835 sender->handle(
this,
contents.empty() ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE), ptr);
873 FXint cl, ch, xx, xlo, xhi;
874 if ((state ^ flags) & FLAG_CARET) {
885 xlo = FXMAX(xx - 2, border);
886 xhi = FXMIN(xx + 3, width - border);
888 dc.setClipRectangle(xlo, border, xhi - xlo, height - (border << 1));
890 if (state & FLAG_CARET) {
893 dc.fillRectangle(xx, padtop + border, 1, height - padbottom - padtop - (border << 1));
894 dc.fillRectangle(xx - 2, padtop + border, 5, 1);
895 dc.fillRectangle(xx - 2, height - border - padbottom - 1, 5, 1);
898 dc.setForeground(backColor);
899 dc.fillRectangle(xx - 2, border, 5, height - (border << 1));
924 FXint rr = width - border - padright;
925 FXint ll = border + padleft;
933 if (options & TEXTFIELD_PASSWD) {
940 if (options & JUSTIFY_RIGHT) {
948 }
else if (options & JUSTIFY_LEFT) {
972 flags &= ~(FXuint)FLAG_DIRTY;
978 FXint rr = width - border - padright;
979 FXint ll = border + padleft;
987 if (options & JUSTIFY_RIGHT) {
988 if (options & TEXTFIELD_PASSWD) {
998 }
else if (options & JUSTIFY_LEFT) {
999 if (options & TEXTFIELD_PASSWD) {
1010 if (options & TEXTFIELD_PASSWD) {
1022 update(border, border, width - (border << 1), height - (border << 1));
1029 FXint rr = width - border - padright;
1030 FXint ll = border + padleft;
1031 FXint mm = (ll + rr) / 2;
1033 if (options & TEXTFIELD_PASSWD) {
1034 cw =
myFont->getTextWidth(
"*", 1);
1035 if (options & JUSTIFY_RIGHT) {
1037 }
else if (options & JUSTIFY_LEFT) {
1040 xx = mm - (cw *
contents.count()) / 2;
1043 pos =
contents.offset((x - xx + (cw >> 1)) / cw);
1045 if (options & JUSTIFY_RIGHT) {
1047 }
else if (options & JUSTIFY_LEFT) {
1055 if (x < (xx + (cw >> 1))) {
1073 FXint rr = width - border - padright;
1074 FXint ll = border + padleft;
1075 FXint mm = (ll + rr) / 2;
1077 FXASSERT(0 <= i && i <=
contents.length());
1078 if (options & JUSTIFY_RIGHT) {
1079 if (options & TEXTFIELD_PASSWD) {
1084 }
else if (options & JUSTIFY_LEFT) {
1085 if (options & TEXTFIELD_PASSWD) {
1091 if (options & TEXTFIELD_PASSWD) {
1103 if (0 <= pos && pos <=
contents.length()) {
1105 return border + padleft <= x && x <= width - border - padright;
1120 y +=
myFont->getFontAscent();
1121 dc.drawText(x, y, &
contents[fm], to - fm);
1127 FXint cw =
myFont->getTextWidth(
"*", 1);
1129 y +=
myFont->getFontAscent();
1131 for (i = fm; i < to; i =
contents.inc(i), x += cw) {
1132 dc.drawText(x, y,
"*", 1);
1139 FXint sx, ex, xx, yy, cw, hh, ww, si, ei, lx, rx, t;
1140 FXint rr = width - border - padright;
1141 FXint ll = border + padleft;
1142 FXint mm = (ll + rr) / 2;
1151 hh =
myFont->getFontHeight();
1153 if (options & JUSTIFY_TOP) {
1154 yy = padtop + border;
1155 }
else if (options & JUSTIFY_BOTTOM) {
1157 yy = height - padbottom - border - hh;
1160 yy = border + padtop + (height - padbottom - padtop - (border << 1) - hh) / 2;
1170 if (options & TEXTFIELD_PASSWD) {
1171 cw =
myFont->getTextWidth(
"*", 1);
1174 if (options & JUSTIFY_RIGHT) {
1176 }
else if (options & JUSTIFY_LEFT) {
1198 if (rx - cw < width) {
1213 if (!hasSelection() || to <= si || ei <= fm) {
1232 dc.fillRectangle(sx, padtop + border, ex - sx, height - padtop - padbottom - (border << 1));
1236 dc.setForeground(baseColor);
1237 dc.fillRectangle(sx, padtop + border, ex - sx, height - padtop - padbottom - (border << 1));
1247 if (options & JUSTIFY_RIGHT) {
1249 }
else if (options & JUSTIFY_LEFT) {
1275 if (rx - cw < width) {
1291 if (!hasSelection() || to <= si || ei <= fm) {
1310 dc.fillRectangle(sx, padtop + border, ex - sx, height - padtop - padbottom - (border << 1));
1314 dc.setForeground(baseColor);
1315 dc.fillRectangle(sx, padtop + border, ex - sx, height - padtop - padbottom - (border << 1));
1344 return FXFrame::onEnter(sender, sel, ptr);
1355 return FXFrame::onLeave(sender, sel, ptr);
1361 FXEvent* ev = (FXEvent*)ptr;
1362 FXDCWindow dc(
this, ev);
1364 drawFrame(dc, 0, 0, width, height);
1367 dc.setForeground(backColor);
1369 dc.setForeground(baseColor);
1372 dc.fillRectangle(border, border, width - (border << 1), height - (border << 1));
1374 dc.setClipRectangle(border, border, width - (border << 1), height - (border << 1));
1377 if (flags & FLAG_CARET) {
1384 dc.fillRectangle(xx, padtop + border, 1, height - padbottom - padtop - (border << 1));
1385 dc.fillRectangle(xx - 2, padtop + border, 5, 1);
1386 dc.fillRectangle(xx - 2, height - border - padbottom - 1, 5, 1);
1431 return w < 128 && strchr(myTextDelimiter, w);
1440 FXASSERT(0 <= pos && pos <=
contents.length());
1453 if ((pos == pp) && 0 <= (p =
contents.dec(pp))) {
1466 FXASSERT(0 <= pos && pos <=
contents.length());
1479 if ((pos == pp) && pp <
contents.length()) {
1490 FXASSERT(0 <= pos && pos <=
contents.length());
1510 FXASSERT(0 <= pos && pos <=
contents.length());
1592 if (hasSelection()) {
1593 FXDragType types[4];
1594 types[0] = stringType;
1595 types[1] = textType;
1596 types[2] = utf8Type;
1597 types[3] = utf16Type;
1598 if (acquireClipboard(types, 4)) {
1604 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_DELETE_SEL), NULL);
1616 if (hasSelection()) {
1617 FXDragType types[4];
1618 types[0] = stringType;
1619 types[1] = textType;
1620 types[2] = utf8Type;
1621 types[3] = utf16Type;
1622 if (acquireClipboard(types, 4)) {
1640 if (hasSelection()) {
1641 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_DELETE_SEL), NULL);
1645 if (getDNDData(FROM_CLIPBOARD, utf8Type,
string)) {
1646 FXTRACE((100,
"Paste UTF8\n"));
1647 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_INSERT_STRING), (
void*)
string.text());
1652 if (getDNDData(FROM_CLIPBOARD, utf16Type,
string)) {
1653 FXUTF16LECodec unicode;
1654 FXTRACE((100,
"Paste UTF16\n"));
1655 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_INSERT_STRING), (
void*)unicode.mb2utf(
string).text());
1660 if (getDNDData(FROM_CLIPBOARD, stringType,
string)) {
1662 FXTRACE((100,
"Paste ASCII\n"));
1663 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_INSERT_STRING), (
void*)ascii.mb2utf(
string).text());
1679 if (getDNDData(FROM_SELECTION, utf8Type,
string)) {
1680 FXTRACE((100,
"Paste UTF8\n"));
1681 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_INSERT_STRING), (
void*)
string.text());
1686 if (getDNDData(FROM_SELECTION, utf16Type,
string)) {
1687 FXUTF16LECodec unicode;
1688 FXTRACE((100,
"Paste UTF16\n"));
1689 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_INSERT_STRING), (
void*)unicode.mb2utf(
string).text());
1694 if (getDNDData(FROM_SELECTION, stringType,
string)) {
1696 FXTRACE((100,
"Paste ASCII\n"));
1697 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_INSERT_STRING), (
void*)ascii.mb2utf(
string).text());
1710 if (!hasSelection()) {
1721 flags |= FLAG_CHANGED;
1723 target->tryHandle(
this, FXSEL(SEL_CHANGED, message), (
void*)
contents.text());
1741 flags |= FLAG_CHANGED;
1743 target->tryHandle(
this, FXSEL(SEL_CHANGED, message), (
void*)
contents.text());
1756 FXint len = (int)strlen((FXchar*)ptr);
1759 if (hasSelection()) {
1763 tentative.replace(reppos, replen, (FXchar*)ptr, len);
1764 if (handle(
this, FXSEL(SEL_VERIFY, 0), (
void*)tentative.text())) {
1776 update(border, border, width - (border << 1), height - (border << 1));
1777 flags |= FLAG_CHANGED;
1779 target->tryHandle(
this, FXSEL(SEL_CHANGED, message), (
void*)
contents.text());
1792 FXint len = (int)strlen((FXchar*)ptr);
1795 if (hasSelection()) {
1799 tentative.replace(reppos, replen, (FXchar*)ptr, len);
1800 if (handle(
this, FXSEL(SEL_VERIFY, 0), (
void*)tentative.text())) {
1812 update(border, border, width - (border << 1), height - (border << 1));
1813 flags |= FLAG_CHANGED;
1815 target->tryHandle(
this, FXSEL(SEL_CHANGED, message), (
void*)
contents.text());
1833 update(border, border, width - (border << 1), height - (border << 1));
1834 flags |= FLAG_CHANGED;
1836 target->tryHandle(
this, FXSEL(SEL_CHANGED, message), (
void*)
contents.text());
1853 update(border, border, width - (border << 1), height - (border << 1));
1854 flags |= FLAG_CHANGED;
1856 target->tryHandle(
this, FXSEL(SEL_CHANGED, message), (
void*)
contents.text());
1867 FXchar* p = (FXchar*)ptr;
1870 if (options & TEXTFIELD_LIMITED) {
1877 if (options & TEXTFIELD_INTEGER) {
1878 while (Ascii::isSpace(*p)) {
1881 if (*p ==
'-' || *p ==
'+') {
1884 while (Ascii::isDigit(*p)) {
1887 while (Ascii::isSpace(*p)) {
1896 if (options & TEXTFIELD_REAL) {
1897 while (Ascii::isSpace(*p)) {
1900 if (*p ==
'-' || *p ==
'+') {
1903 while (Ascii::isDigit(*p)) {
1909 while (Ascii::isDigit(*p)) {
1912 if (*p ==
'E' || *p ==
'e') {
1914 if (*p ==
'-' || *p ==
'+') {
1917 while (Ascii::isDigit(*p)) {
1921 while (Ascii::isSpace(*p)) {
1930 if (target && target->tryHandle(
this, FXSEL(SEL_VERIFY, message), ptr)) {
1941 FXEvent*
event = (FXEvent*)ptr;
1944 FXTRACE((200,
"%s::onKeyPress keysym = 0x%04x state = %04x\n", getClassName(), event->code, event->state));
1945 if (target && target->tryHandle(
this, FXSEL(SEL_KEYPRESS, message), ptr)) {
1948 flags &= ~FLAG_UPDATE;
1949 switch (event->code) {
1952 if (!(event->state & SHIFTMASK)) {
1953 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_DESELECT_ALL), NULL);
1955 if (event->state & CONTROLMASK) {
1956 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_CURSOR_WORD_RIGHT), NULL);
1958 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_CURSOR_RIGHT), NULL);
1960 if (event->state & SHIFTMASK) {
1961 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_EXTEND), NULL);
1963 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_MARK), NULL);
1968 if (!(event->state & SHIFTMASK)) {
1969 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_DESELECT_ALL), NULL);
1971 if (event->state & CONTROLMASK) {
1972 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_CURSOR_WORD_LEFT), NULL);
1974 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_CURSOR_LEFT), NULL);
1976 if (event->state & SHIFTMASK) {
1977 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_EXTEND), NULL);
1979 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_MARK), NULL);
1984 if (!(event->state & SHIFTMASK)) {
1985 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_DESELECT_ALL), NULL);
1987 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_CURSOR_HOME), NULL);
1988 if (event->state & SHIFTMASK) {
1989 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_EXTEND), NULL);
1991 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_MARK), NULL);
1996 if (!(event->state & SHIFTMASK)) {
1997 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_DESELECT_ALL), NULL);
1999 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_CURSOR_END), NULL);
2000 if (event->state & SHIFTMASK) {
2001 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_EXTEND), NULL);
2003 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_MARK), NULL);
2008 if (event->state & CONTROLMASK) {
2009 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_COPY_SEL), NULL);
2010 }
else if (event->state & SHIFTMASK) {
2011 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_PASTE_SEL), NULL);
2013 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_TOGGLE_OVERSTRIKE), NULL);
2018 if (hasSelection()) {
2019 if (event->state & SHIFTMASK) {
2020 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_CUT_SEL), NULL);
2022 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_DELETE_SEL), NULL);
2025 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_DELETE), NULL);
2029 if (hasSelection()) {
2030 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_DELETE_SEL), NULL);
2032 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_BACKSPACE), NULL);
2038 flags |= FLAG_UPDATE;
2039 flags &= ~FLAG_CHANGED;
2041 target->tryHandle(
this, FXSEL(SEL_COMMAND, message), (
void*)
contents.text());
2048 if (!(event->state & CONTROLMASK)) {
2051 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_SELECT_ALL), NULL);
2054 if (!(event->state & CONTROLMASK)) {
2059 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_CUT_SEL), NULL);
2062 if (!(event->state & CONTROLMASK)) {
2067 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_COPY_SEL), NULL);
2070 if (!(event->state & CONTROLMASK)) {
2075 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_PASTE_SEL), NULL);
2080 if ((event->state & (CONTROLMASK | ALTMASK)) || ((FXuchar)event->text[0] < 32)) {
2084 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_OVERST_STRING), (
void*)event->text.text());
2086 handle(
this, FXSEL(SEL_COMMAND, FXTextField::ID_INSERT_STRING), (
void*)event->text.text());
2096 FXEvent*
event = (FXEvent*)ptr;
2098 FXTRACE((200,
"%s::onKeyRelease keysym = 0x%04x state = %04x\n", getClassName(), ((FXEvent*)ptr)->code, ((FXEvent*)ptr)->state));
2099 if (target && target->tryHandle(
this, FXSEL(SEL_KEYRELEASE, message), ptr)) {
2102 switch (event->code) {
2125 if (event->state & CONTROLMASK) {
2130 if ((event->state & (CONTROLMASK | ALTMASK)) || ((FXuchar)event->text[0] < 32)) {
2142 if (hasSelection()) {
2144 update(border, border, width - (border << 1), height - (border << 1));
2171 FXDragType types[4];
2178 types[0] = stringType;
2179 types[1] = textType;
2180 types[2] = utf8Type;
2181 types[3] = utf16Type;
2182 if (!hasSelection()) {
2183 acquireSelection(types, 4);
2186 if (hasSelection()) {
2191 update(border, border, width - (border << 1), height - (border << 1));
2206 if (notify && target) {
2207 target->tryHandle(
this, FXSEL(SEL_COMMAND, message), (
void*)
contents.text());
2308 return (options & TEXTFIELD_READONLY) == 0;
2316 options &= ~TEXTFIELD_READONLY;
2318 options |= TEXTFIELD_READONLY;
2326 return (options & TEXTFIELD_OVERSTRIKE) != 0;
2334 options |= TEXTFIELD_OVERSTRIKE;
2336 options &= ~TEXTFIELD_OVERSTRIKE;
2343 FXuint opts = (options & ~TEXTFIELD_MASK) | (style &
TEXTFIELD_MASK);
2344 if (options != opts) {
2363 FXuint opts = (options & ~JUSTIFY_MASK) | (style &
JUSTIFY_MASK);
2364 if (options != opts) {
2423 flags |= FLAG_ENABLED;
#define GUIDesignTextFieldNCol
Num of column of text field.
GUIIcon
An enumeration of icons used by the gui applications.
static FXbool isdelimiter(const FXchar *myTextDelimiter, FXwchar w)
FXDEFMAP(MFXTextFieldIcon) MFXTextFieldIconMap[]
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
FXint myShiftAmount
Shift amount.
void setToolTipText(const FXString &toolTip)
set toolTip
FXString contents
Edited text.
long onCmdOverstString(FXObject *, FXSelector, void *)
virtual void disable()
Disable text field.
FXint coord(FXint i) const
coordinates
long onCmdSelectAll(FXObject *, FXSelector, void *)
long onCmdGetStringValue(FXObject *, FXSelector, void *)
FXint myAnchorPosition
Anchor position.
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 *)
FXString myTooltipText
Tooltip.
long onCmdGetHelp(FXObject *, FXSelector, void *)
long onBlink(FXObject *, FXSelector, void *)
long onCmdCursorHome(FXObject *, FXSelector, void *)
long onCmdCursorWordStart(FXObject *, FXSelector, void *)
FXString myClippedText
Clipped text.
long onLeave(FXObject *, FXSelector, void *)
const FXString & getTipText() const
Get the tool tip message for this text field.
long onKeyPress(FXObject *, FXSelector, void *)
FXint getCursorPos() const
Return cursor position.
FXFont * myFont
Text font.
FXint myVisibleColumns
Number of myVisibleColumns visible.
FXString myHelpText
Help string.
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
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.
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 *)
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.
long onUpdToggleOverstrike(FXObject *, FXSelector, void *)
long onVerify(FXObject *, FXSelector, void *)
FXint leftWord(FXint pos) const
left word
long onCmdCursorLeft(FXObject *, FXSelector, void *)
FXint myCursorPosition
Cursor position.
MFXStaticToolTip * myStaticToolTip
static tooltip
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 *)
const FXchar * myTextDelimiter
Set of text delimiter.
long onCmdCursorWordEnd(FXObject *, FXSelector, void *)
void drawCursor(FXuint state)
draw myCursorPosition
void setAnchorPos(FXint pos)
Change anchor position.
FXColor getTextColor() const
Return text color.
long onKeyRelease(FXObject *, FXSelector, void *)
long onSelectionRequest(FXObject *, FXSelector, void *ptr)
long onCmdDelete(FXObject *, FXSelector, void *)
FXColor myCursorColor
Color of the Cursor.
long onCmdDeleteSel(FXObject *, FXSelector, void *)
long onClipboardLost(FXObject *, FXSelector, void *)
long onCmdSetRealValue(FXObject *, FXSelector, void *)
long onCmdCursorEnd(FXObject *, FXSelector, void *)
virtual bool canFocus() const
Yes, text field may receive focus.
long onCmdSetValue(FXObject *, FXSelector, void *)
void setCursorPos(FXint pos)
Set cursor position.
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.
FXColor mySelectedBackgroundColor
Selected background color.
long onUpdSelectAll(FXObject *, FXSelector, void *)
FXint index(FXint x) const
index
long onCmdPasteMiddle(FXObject *, FXSelector, void *)
long onCmdCursorWordLeft(FXObject *, FXSelector, void *)
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 *)
FXColor myTextColor
Text color.
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.
FXint getAnchorPos() const
Return anchor position.
long onUpdToggleEditable(FXObject *, FXSelector, void *)
long onEnter(FXObject *, FXSelector, void *)
fox callbacks
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 *)
FXint getNumColumns() const
Return number of columns.
long onCmdToggleEditable(FXObject *, FXSelector, void *)
long onCmdSetHelp(FXObject *, FXSelector, void *)
long onCmdInsertString(FXObject *, FXSelector, void *)
FXFont * getFont() const
Get the text font.
long onPaint(FXObject *, FXSelector, void *)
long onCmdDeleteAll(FXObject *, FXSelector, void *)
const FXString & getHelpText() const
Get the status line help text for this label.
const FXchar * getDelimiters() const
Return word delimiters.
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.
void setDelimiters(const FXchar *delims=FXTextField::textDelimiters)
Change word delimiters.
FXString myToolTipText
toolTip text (if set, tooltip will be always show)
long onCmdSetIntValue(FXObject *, FXSelector, void *)
void setTextStyle(FXuint style)
Change text style.
FXColor getSelTextColor() const
Return selected text color.
FXColor mySelectedTextColor
Selected text color.
long onCmdCursorRight(FXObject *, FXSelector, void *)
FXColor getCursorColor() const
Return the cursor color.
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 *)