~ubuntu-branches/ubuntu/karmic/fltk1.1/karmic

« back to all changes in this revision

Viewing changes to src/Fl_Input_.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Aaron M. Ucko
  • Date: 2005-05-22 13:57:06 UTC
  • mfrom: (2.1.1 hoary)
  • Revision ID: james.westby@ubuntu.com-20050522135706-mchag24yf42lu7bu
Tags: 1.1.6-5
* Revert previous change, which seems to have been ineffective for some
  reason, in favor of commenting out the problematic Makefile rule
  altogether.  (Closes: #310151.)
* debian/control: Go back to specifying the URL as part of the
  description rather than via a non-standard field that doesn't seem to
  have caught on.  (Closes: #310240.)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//
2
 
// "$Id: Fl_Input_.cxx,v 1.21.2.11.2.29 2004/04/11 04:38:57 easysw Exp $"
 
2
// "$Id: Fl_Input_.cxx,v 1.21.2.11.2.32 2004/09/21 13:35:39 easysw Exp $"
3
3
//
4
4
// Common input widget routines for the Fast Light Tool Kit (FLTK).
5
5
//
40
40
 
41
41
#define MAXBUF 1024
42
42
 
 
43
extern void fl_draw(const char*, int, float, float);
 
44
 
43
45
////////////////////////////////////////////////////////////////
44
46
 
45
47
// Copy string p..e to the buffer, replacing characters with ^X and \nnn
222
224
  p = value();
223
225
  // visit each line and draw it:
224
226
  int desc = height-fl_descent();
225
 
  int xpos = X - xscroll_ + 1;
 
227
  float xpos = X - xscroll_ + 1;
226
228
  int ypos = -yscroll_;
227
229
  for (; ypos < H;) {
228
230
 
237
239
      if (readonly()) erase_cursor_only = 0; // this isn't the most efficient way
238
240
      if (erase_cursor_only && p > pp) goto CONTINUE2; // this line is after
239
241
      // calculate area to erase:
240
 
      int r = X+W;
241
 
      int xx;
 
242
      float r = X+W;
 
243
      float xx;
242
244
      if (p >= pp) {
243
245
        xx = X;
244
246
        if (erase_cursor_only) r = xpos+2;
245
247
        else if (readonly()) xx -= 3;
246
248
      } else {
247
 
        xx = xpos+(int)expandpos(p, pp, buf, 0);
 
249
        xx = xpos+expandpos(p, pp, buf, 0);
248
250
        if (erase_cursor_only) r = xx+2;
249
251
        else if (readonly()) xx -= 3;
250
252
      }
251
253
      // clip to and erase it:
252
 
      fl_push_clip(xx, Y+ypos, r-xx, height);
 
254
      fl_push_clip((int)xx, Y+ypos, (int)(r-xx+1), height);
253
255
      draw_box(box(), X-Fl::box_dx(box()), Y-Fl::box_dy(box()),
254
256
               W+Fl::box_dw(box()), H+Fl::box_dh(box()), color());
255
257
      // it now draws entire line over it
260
262
    // Draw selection area if required:
261
263
    if (selstart < selend && selstart <= e-value() && selend > p-value()) {
262
264
      const char* pp = value()+selstart;
263
 
      int x1 = xpos;
 
265
      float x1 = xpos;
264
266
      int offset1 = 0;
265
267
      if (pp > p) {
266
268
        fl_color(tc);
267
 
        x1 += int(expandpos(p, pp, buf, &offset1));
268
 
        fl_draw(buf, offset1, xpos, Y+ypos+desc);
 
269
        x1 += expandpos(p, pp, buf, &offset1);
 
270
        fl_draw(buf, offset1, xpos, (float)(Y+ypos+desc));
269
271
      }
270
272
      pp = value()+selend;
271
 
      int x2 = X+W;
 
273
      float x2 = X+W;
272
274
      int offset2;
273
 
      if (pp <= e) x2 = xpos+int(expandpos(p, pp, buf, &offset2));
 
275
      if (pp <= e) x2 = xpos+expandpos(p, pp, buf, &offset2);
274
276
      else offset2 = strlen(buf);
275
277
      fl_color(selection_color());
276
 
      fl_rectf(x1, Y+ypos, x2-x1, height);
 
278
      fl_rectf((int)(x1+0.5), Y+ypos, (int)(x2-x1+0.5), height);
277
279
      fl_color(fl_contrast(textcolor(), selection_color()));
278
 
      fl_draw(buf+offset1, offset2-offset1, x1, Y+ypos+desc);
 
280
      fl_draw(buf+offset1, offset2-offset1, x1, (float)(Y+ypos+desc));
279
281
      if (pp < e) {
280
282
        fl_color(tc);
281
 
        fl_draw(buf+offset2, x2, Y+ypos+desc);
 
283
        fl_draw(buf+offset2, strlen(buf+offset2), x2, (float)(Y+ypos+desc));
282
284
      }
283
285
    } else {
284
286
      // draw unselected text
285
287
      fl_color(tc);
286
 
      fl_draw(buf, xpos, Y+ypos+desc);
 
288
      fl_draw(buf, strlen(buf), xpos, (float)(Y+ypos+desc));
287
289
    }
288
290
 
289
291
    if (do_mu) fl_pop_clip();
294
296
        position() >= p-value() && position() <= e-value()) {
295
297
      fl_color(cursor_color());
296
298
      if (readonly()) {
297
 
        fl_line(xpos+curx-3, Y+ypos+height-1,
298
 
                xpos+curx, Y+ypos+height-4,
299
 
                xpos+curx+3, Y+ypos+height-1);
 
299
        fl_line((int)(xpos+curx-2.5f), Y+ypos+height-1,
 
300
                (int)(xpos+curx+0.5f), Y+ypos+height-4,
 
301
                (int)(xpos+curx+3.5f), Y+ypos+height-1);
300
302
      } else {
301
 
        fl_rectf(xpos+curx, Y+ypos, 2, height);
 
303
        fl_rectf((int)(xpos+curx+0.5), Y+ypos, 2, height);
302
304
      }
303
305
    }
304
306
 
599
601
 
600
602
  mark_ = position_ = undoat;
601
603
 
602
 
  if (when()&FL_WHEN_CHANGED) do_callback(); else set_changed();
 
604
  set_changed();
 
605
  if (when()&FL_WHEN_CHANGED) do_callback();
603
606
  return 1;
604
607
}
605
608
 
636
639
  position_ = b;
637
640
 
638
641
  minimal_update(b1);
639
 
  if (when()&FL_WHEN_CHANGED) do_callback(); else set_changed();
 
642
  set_changed();
 
643
  if (when()&FL_WHEN_CHANGED) do_callback();
640
644
  return 1;
641
645
}
642
646
 
649
653
 
650
654
void Fl_Input_::maybe_do_callback() {
651
655
  if (changed() || (when()&FL_WHEN_NOT_CHANGED)) {
652
 
    clear_changed(); do_callback();}
 
656
    do_callback();
 
657
  }
653
658
}
654
659
 
655
660
int Fl_Input_::handletext(int event, int X, int Y, int W, int H) {
788
793
    } else {
789
794
      bufsize = len+1;
790
795
    }
 
796
    // Note: the following code is equivalent to:
 
797
    //
 
798
    //   if (moveit) value_ = value_ - buffer;
 
799
    //   char* nbuffer = (char*)realloc(buffer, bufsize);
 
800
    //   if (moveit) value_ = value_ + nbuffer;
 
801
    //   buffer = nbuffer;
 
802
    //
 
803
    // We just optimized the pointer arithmetic for value_...
 
804
    //
791
805
    char* nbuffer = (char*)realloc(buffer, bufsize);
792
806
    if (moveit) value_ += (nbuffer-buffer);
793
807
    buffer = nbuffer;
852
866
}
853
867
 
854
868
//
855
 
// End of "$Id: Fl_Input_.cxx,v 1.21.2.11.2.29 2004/04/11 04:38:57 easysw Exp $".
 
869
// End of "$Id: Fl_Input_.cxx,v 1.21.2.11.2.32 2004/09/21 13:35:39 easysw Exp $".
856
870
//