Ejemplo n.º 1
0
Scheme_Object*
spark_fltk_scroll::xposition(int argc, Scheme_Object** argv)
{
  DEFAULT_RET_INIT;

  Fl_Scroll* scroll = _get_fl_scroll(argc, argv, 0);
  if (scroll)
    _ret_ = scheme_make_integer(scroll->xposition());

  DEFAULT_RET_FINISH;
}
Ejemplo n.º 2
0
int Fl_Canvas::handle (int event) {
    if (Fl_Group::handle (event)) return 1;
    if (event==FL_PUSH) {
       ClearIncompleteWire();
       redraw();
       m_DragX=Fl::event_x();
       m_DragY=Fl::event_y();
    }
    if ((Fl::event_button() == 1) && ((Fl::event_state() & FL_SHIFT) == 0) && ((Fl::event_state() & FL_CTRL) == 0)) {
       // Left-Click  (or plain click for those who are mouse-button challenged)
       // Select / Multi-select / move devices
       // Handled below - If on a non-selected plugin, deselect and move
       // Handled below - If on a selected plugin, move selection
       // Handled Here - If on canvas - multi select
       if (event==FL_PUSH) {
          if (m_HaveSelection) {
             m_Selection.Clear();
             m_HaveSelection = false;
          }
          m_Selecting = true;
          m_StartSelectX=Fl::event_x();
          m_StartSelectY=Fl::event_y();
          m_EndSelectX=Fl::event_x();
          m_EndSelectY=Fl::event_y();
          ClearIncompleteWire();
          redraw();
          m_DragX=Fl::event_x();
          m_DragY=Fl::event_y();
       }
       if ((event==FL_DRAG) && m_Selecting) {
          m_EndSelectX = Fl::event_x();
          m_EndSelectY = Fl::event_y();
          Fl_Scroll* scroll = (Fl_Scroll *)parent();
          int newx = 0, xp = scroll->xposition();
          int newy = 0, yp = scroll->yposition();
          if ((m_EndSelectX < m_StartSelectX) && ((m_EndSelectX - x() - xp) <= 15))
             newx = 10;
          if ((m_EndSelectY < m_StartSelectY) && ((m_EndSelectY - y() - yp) <= 15))
             newy = 10;
          if ((m_EndSelectX > m_StartSelectX) && ((scroll->x() + scroll->w() - m_EndSelectX - 15) <= 15))
             newx = -10;
          if ((m_EndSelectY > m_StartSelectY) && ((scroll->y() + scroll->h() - m_EndSelectY - 15) <= 5))
             newy = -10;
          if ((newx!=0) || (newy!=0)) {
             position(x()+newx,y()+newy);
             m_StartSelectX += newx;
             m_StartSelectY += newy;
          }
          m_DragX=Fl::event_x();
          m_DragY=Fl::event_y();
          redraw();
       }
       if ((event==FL_RELEASE) && m_Selecting) {
          m_Selecting = false;
          if ((m_EndSelectX != m_StartSelectX) && (m_EndSelectY != m_StartSelectY))
             CalculateSelection();
          redraw();
       }
    }
    if ((Fl::event_button() == 2) || ((Fl::event_button() == 1) && ((Fl::event_state() & FL_SHIFT) != 0))) {
       // Middle-Click  (or shift-click for the mouse button challenged) - old left click
       // Handled Below - If on items allows selecting of individual items
       // Handled Here - If on canvas, drags canvas
       if (event==FL_PUSH) {
          ClearIncompleteWire();
          redraw();
          m_DragX=Fl::event_x();
          m_DragY=Fl::event_y();
       }
       if (event==FL_DRAG) {
          position (x() + (Fl::event_x() - m_DragX), y() + (Fl::event_y() - m_DragY));
          m_DragX=Fl::event_x();
          m_DragY=Fl::event_y();
          redraw();
       }
    }
    if ((Fl::event_button() == 3) || ((Fl::event_button() == 1) && ((Fl::event_state() & FL_CTRL) != 0))) {
       // Right-Click (or Ctrl-click for the M.B.C.)
       // Pop-up Edit/Plugins menu
       if (event==FL_PUSH) {
          m_x=Fl::event_x();
          m_y=Fl::event_y();
          PopupEditMenu (this);
       }
    }
    return 1;
}