void BC_TextBox::default_keypress(int &dispatch_event, int &result)
{
int key = top_level->get_keypress(), len;
- if( (key == RETURN) || ( key >= 32 && key <= 255 ) ||
- (key >= KP1 && key <= KP9) || key == KPINS ) {
- wchar_t *wkeys = top_level->get_wkeystring(&len);
- switch( key ) {
- case RETURN: key = '\n'; goto kpchr;
- case KPINS: key = '0'; goto kpchr;
- case KP1: case KP2: case KP3: case KP4: case KP5:
- case KP6: case KP7: case KP8: case KP9:
- key = key - KP1 + '1';
- kpchr:
- wkeys[0] = key; wkeys[1] = 0; len = 1;
- break;
- }
- insert_text(wkeys, len);
- find_ibeam(1);
- draw(1);
- dispatch_event = 1;
- result = 1;
- }
+ wchar_t *wkeys = top_level->get_wkeystring(&len);
+ switch( key ) {
+ case KPENTER: key = '\n'; goto kpchr;
+ case KPMINUS: key = '-'; goto kpchr;
+ case KPPLUS: key = '+'; goto kpchr;
+ case KPDEL: key = '.'; goto kpchr;
+ case RETURN: key = '\n'; goto kpchr;
+ case KPINS: key = '0'; goto kpchr;
+ case KP1: case KP2: case KP3: case KP4: case KP5:
+ case KP6: case KP7: case KP8: case KP9:
+ key = key - KP1 + '1'; goto kpchr;
+ default:
+ if( key < 32 || key > 255 ) return;
+ kpchr: {
+ wkeys[0] = key; wkeys[1] = 0; len = 1;
+ break; }
+ }
+ insert_text(wkeys, len);
+ find_ibeam(1);
+ draw(1);
+ dispatch_event = 1;
+ result = 1;
}
int BC_TextBox::keypress_event()
}
}
+Motion51VVFrame::Motion51VVFrame(VFrame *vfrm, int n)
+ : VFrame(vfrm->get_data(), -1, vfrm->get_y()-vfrm->get_data(),
+ vfrm->get_u()-vfrm->get_data(), vfrm->get_v()-vfrm->get_data(),
+ vfrm->get_w(), vfrm->get_h(), vfrm->get_color_model(),
+ vfrm->get_bytes_per_line())
+{
+ this->n = n;
+}
+
+int Motion51VVFrame::draw_pixel(int x, int y)
+{
+ VFrame::draw_pixel(x+0, y+0);
+ for( int i=1; i<n; ++i ) {
+ VFrame::draw_pixel(x-i, y+0);
+ VFrame::draw_pixel(x+0, y+i);
+ VFrame::draw_pixel(x+i, y+0);
+ VFrame::draw_pixel(x+0, y-i);
+ }
+ return 0;
+}
void Motion51Main::draw_vectors(VFrame *img)
{
- img->draw_arrow(rx, ry, rx+current_dx, ry+current_dy);
+ int iw = img->get_w(), ih = img->get_h();
+ int mx = iw > ih ? iw : ih;
+ Motion51VVFrame vfrm(img, mx/800+1);
-// img->draw_smooth(rx-rr,ry, rx-rr,ry+rr, rx,ry+rr);
-// img->draw_smooth(rx,ry+rr, rx+rr,ry+rr, rx+rr,ry);
-// img->draw_smooth(rx+rr,ry, rx+rr,ry-rr, rx,ry-rr);
-// img->draw_smooth(rx,ry-rr, rx-rr,ry-rr, rx-rr,ry);
+ vfrm.draw_arrow(rx, ry, rx+current_dx, ry+current_dy);
+// vfrm.draw_smooth(rx-rr,ry, rx-rr,ry+rr, rx,ry+rr);
+// vfrm.draw_smooth(rx,ry+rr, rx+rr,ry+rr, rx+rr,ry);
+// vfrm.draw_smooth(rx+rr,ry, rx+rr,ry-rr, rx,ry-rr);
+// vfrm.draw_smooth(rx,ry-rr, rx-rr,ry-rr, rx-rr,ry);
float rx1 = rx - 0.5*rw;
float ry1 = ry - 0.5*rh;
float rx2 = rx1 + rw;
float ry2 = ry1 + rh;
- img->draw_line(rx1, ry1, rx2, ry1);
- img->draw_line(rx2, ry1, rx2, ry2);
- img->draw_line(rx2, ry2, rx1, ry2);
- img->draw_line(rx1, ry2, rx1, ry1);
+ vfrm.draw_line(rx1, ry1, rx2, ry1);
+ vfrm.draw_line(rx2, ry1, rx2, ry2);
+ vfrm.draw_line(rx2, ry2, rx1, ry2);
+ vfrm.draw_line(rx1, ry2, rx1, ry1);
float sx1 = rx1 - rr, sy1 = ry1 - rr;
float sx2 = rx2 + rr, sy2 = ry2 + rr;
- img->draw_smooth(sx1, ry1, sx1, sy1, rx1, sy1);
- img->draw_line(rx1, sy1, rx2, sy1);
- img->draw_smooth(rx2, sy1, sx2, sy1, sx2, ry1);
- img->draw_line(sx2, ry1, sx2, ry2);
- img->draw_smooth(sx2, ry2, sx2, sy2, rx2, sy2);
- img->draw_line(rx2, sy2, rx1, sy2);
- img->draw_smooth(rx1, sy2, sx1, sy2, sx1, ry2);
- img->draw_line(sx1, ry2, sx1, ry1);
+ vfrm.draw_smooth(sx1, ry1, sx1, sy1, rx1, sy1);
+ vfrm.draw_line(rx1, sy1, rx2, sy1);
+ vfrm.draw_smooth(rx2, sy1, sx2, sy1, sx2, ry1);
+ vfrm.draw_line(sx2, ry1, sx2, ry2);
+ vfrm.draw_smooth(sx2, ry2, sx2, sy2, rx2, sy2);
+ vfrm.draw_line(rx2, sy2, rx1, sy2);
+ vfrm.draw_smooth(rx1, sy2, sx1, sy2, sx1, ry2);
+ vfrm.draw_line(sx1, ry2, sx1, ry1);
double *xp = xpts, *yp = ypts;
for( int i=cir_sz; --i>=0; ++xp, ++yp )
- img->draw_pixel(rx+*xp, ry+*yp);
+ vfrm.draw_pixel(rx+*xp, ry+*yp);
}
int Motion51Main::open_cache_file()