46 FXint sx, ex, xx, yy, cw, hh, ww, si, ei, lx, rx, t;
47 const FXint rr = width - border - padright;
48 const FXint ll = border + padleft;
49 const FXint mm = (ll + rr) / 2;
55 dc.setForeground(textColor);
57 hh = font->getFontHeight();
59 if (options & JUSTIFY_TOP) {
63 else if (options & JUSTIFY_BOTTOM) {
64 yy = height - padbottom - border - hh;
67 yy = border + padtop + (height - padbottom - padtop - (border << 1) - hh) / 2;
69 if (anchor < cursor) {
77 if (options & TEXTFIELD_PASSWD) {
78 cw = font->getTextWidth(
"*", 1);
79 ww = cw * contents.count();
81 if (options & JUSTIFY_RIGHT) {
82 xx = shift + rr - ww + iconWidth;
83 }
else if (options & JUSTIFY_LEFT) {
85 xx = shift + ll + iconWidth;
88 xx = shift + mm - ww / 2 + iconWidth;
91 lx = xx + cw * contents.index(fm);
92 rx = xx + cw * contents.index(to);
98 fm = contents.inc(fm);
101 if (rx - cw < width) {
105 to = contents.dec(to);
115 if (!hasSelection() || to <= si || ei <= fm) {
116 drawPWDTextFragment(dc, xx, yy, fm, to);
120 drawPWDTextFragment(dc, xx, yy, fm, si);
125 drawPWDTextFragment(dc, xx, yy, ei, to);
130 sx = xx + cw * contents.index(si);
131 ex = xx + cw * contents.index(ei);
133 dc.setForeground(selbackColor);
134 dc.fillRectangle(sx, padtop + border, ex - sx, height - padtop - padbottom - (border << 1));
135 dc.setForeground(seltextColor);
136 drawPWDTextFragment(dc, xx, yy, si, ei);
138 dc.setForeground(baseColor);
139 dc.fillRectangle(sx, padtop + border, ex - sx, height - padtop - padbottom - (border << 1));
140 dc.setForeground(textColor);
141 drawPWDTextFragment(dc, xx, yy, si, ei);
147 ww = font->getTextWidth(contents.text(), contents.length());
149 if (options & JUSTIFY_RIGHT) {
150 xx = shift + rr - ww + iconWidth;
151 }
else if (options & JUSTIFY_LEFT) {
153 xx = shift + ll + iconWidth;
156 xx = shift + mm - ww / 2 + iconWidth;
159 lx = xx + font->getTextWidth(&contents[0], fm);
160 rx = lx + font->getTextWidth(&contents[fm], to - fm);
162 t = contents.inc(fm);
163 cw = font->getTextWidth(&contents[fm], t - fm);
171 t = contents.dec(to);
172 cw = font->getTextWidth(&contents[t], to - t);
173 if (rx - cw < width) {
187 if (!hasSelection() || to <= si || ei <= fm) {
188 drawTextFragment(dc, xx, yy, fm, to);
192 drawTextFragment(dc, xx, yy, fm, si);
197 drawTextFragment(dc, xx, yy, ei, to);
202 sx = xx + font->getTextWidth(contents.text(), si);
203 ex = xx + font->getTextWidth(contents.text(), ei);
205 dc.setForeground(selbackColor);
206 dc.fillRectangle(sx, padtop + border, ex - sx, height - padtop - padbottom - (border << 1));
207 dc.setForeground(seltextColor);
208 drawTextFragment(dc, xx, yy, si, ei);
210 dc.setForeground(baseColor);
211 dc.fillRectangle(sx, padtop + border, ex - sx, height - padtop - padbottom - (border << 1));
212 dc.setForeground(textColor);
213 drawTextFragment(dc, xx, yy, si, ei);
220 dc.drawIcon(
myIcon, xx -
myIcon->getWidth() - 3, yy + (hh -
myIcon->getHeight()) / 2);
MFXTextFieldIcon(FXComposite *p, FXint ncols, FXObject *tgt=NULL, FXSelector sel=0, FXuint opts=TEXTFIELD_NORMAL, FXint x=0, FXint y=0, FXint w=0, FXint h=0, FXint pl=DEFAULT_PAD, FXint pr=DEFAULT_PAD, FXint pt=DEFAULT_PAD, FXint pb=DEFAULT_PAD)
constructor
void drawIconTextRange(FXDCWindow &dc, const FXint iconWidth, FXint fm, FXint to)
draw icon text range