45MFXTextFieldSearch::
MFXTextFieldSearch(FXComposite* p, FXint ncols, FXObject* tgt, FXSelector sel, FXuint opt, FXint x, FXint y, FXint w, FXint h, FXint pl, FXint pr, FXint pt, FXint pb) :
46 FXTextField(p, ncols, tgt, sel, opt, x, y, w, h, pl, pr, pt, pb),
60 if (hasFocus() || (contents.count() > 0)) {
61 return FXTextField::onPaint(obj, sel, ptr);
63 FXEvent* ev = (FXEvent*)ptr;
64 FXDCWindow dc(
this, ev);
66 std::string searchString =
TL(
"Type to search...");
68 drawFrame(dc, 0, 0, width, height);
71 dc.setForeground(backColor);
73 dc.setForeground(baseColor);
76 dc.fillRectangle(border, border, width - (border << 1), height - (border << 1));
78 dc.setClipRectangle(border, border, width - (border << 1), height - (border << 1));
81 if (flags & FLAG_CARET) {
82 int xx = coord(cursor) - 1;
83 dc.setForeground(cursorColor);
84 dc.fillRectangle(xx, padtop + border, 1, height - padbottom - padtop - (border << 1));
85 dc.fillRectangle(xx - 2, padtop + border, 5, 1);
86 dc.fillRectangle(xx - 2, height - border - padbottom - 1, 5, 1);
123 FXint xx, yy, cw, hh, ww, si, ei, lx, rx, t;
124 FXint rr = width - border - padright;
125 FXint ll = border + padleft;
126 FXint mm = (ll + rr) / 2;
128 FXint to = (int)searchString.length();
134 dc.setForeground(FXRGBA(128, 128, 128, 255));
136 hh = font->getFontHeight();
138 if (options & JUSTIFY_TOP) {
139 yy = padtop + border;
140 }
else if (options & JUSTIFY_BOTTOM) {
142 yy = height - padbottom - border - hh;
145 yy = border + padtop + (height - padbottom - padtop - (border << 1) - hh) / 2;
147 if (anchor < cursor) {
155 ww = font->getTextWidth(searchString.text(), searchString.length());
157 if (options & JUSTIFY_RIGHT) {
158 xx = shift + rr - ww;
159 }
else if (options & JUSTIFY_LEFT) {
164 xx = shift + mm - ww / 2;
168 lx = xx + font->getTextWidth(&searchString[0], fm);
169 rx = lx + font->getTextWidth(&searchString[fm], to - fm);
171 t = searchString.inc(fm);
172 cw = font->getTextWidth(&searchString[fm], t - fm);
180 t = searchString.dec(to);
181 cw = font->getTextWidth(&searchString[t], to - t);
182 if (rx - cw < width) {
196 xx += font->getTextWidth(searchString.text(), fm);
197 yy += font->getFontAscent();
198 dc.drawText(xx, yy, &searchString[fm], to - fm);
FXDEFMAP(MFXTextFieldSearch) MFXTextFieldSearchMap[]
FXTextFieldIcon (based on FXTextFieldIcon)
long onFocusSelf(FXObject *sender, FXSelector sel, void *ptr)
focus self
long onFocusIn(FXObject *sender, FXSelector sel, void *ptr)
focus in
long onPaint(FXObject *obj, FXSelector sel, void *ptr)
paint
void drawSearchTextRange(const FXString &searchString, FXDCWindow &dc)
draw search text range
long onKeyPress(FXObject *obj, FXSelector sel, void *ptr)
key press
long onFocusOut(FXObject *sender, FXSelector sel, void *ptr)
focus out