int orb_mapctrl::handle(int event) { switch (event) { case FL_MOVE: m_mousepos.set_x(Fl::event_x()-x()); m_mousepos.set_y(Fl::event_y()-y()); return 1; case FL_ENTER: fl_cursor(FL_CURSOR_HAND); return 1; case FL_LEAVE: fl_cursor(FL_CURSOR_DEFAULT); return 1; case FL_PUSH: if (Fl::event_button() == FL_RIGHT_MOUSE) do_callback(); return 1; case FL_RELEASE: return 1; case FL_DRAG: { if (!Fl::event_inside(this)) break; int dx = m_mousepos.get_x() - (Fl::event_x()-x()); int dy = m_mousepos.get_y() - (Fl::event_y()-y()); m_mousepos.set_x(Fl::event_x()-x()); m_mousepos.set_y(Fl::event_y()-y()); m_viewport->move(dx, dy); redraw(); return 1; } case FL_MOUSEWHEEL: if (!Fl::event_inside(this)) break; // Prevent integer underflow if ((Fl::event_dy() > 0) && (m_viewport->z() == 0)) return 1; // The image of the viewport might be smaller then our current // client area. We need to take this delta into account. int dpx = 0, dpy = 0; if (w() > (int)m_viewport->w()) dpx = (w() - (int)m_viewport->w())/2; if (h() > (int)m_viewport->h()) dpy = (h() - (int)m_viewport->h())/2; int px = Fl::event_x()- x() - dpx; int py = Fl::event_y()- y() - dpy; m_viewport->z(m_viewport->z()-Fl::event_dy(), px, py); redraw(); return 1; } return Fl_Widget::handle(event); }
int Flu_Combo_Box :: handle( int event ) { if( event == FL_KEYDOWN && Fl::event_key( FL_Tab ) ) return Fl_Group::handle( event ); // is it time to popup? bool open = ( event == FL_PUSH ) && (!Fl::event_inside( &input ) || ( !editable() && Fl::event_inside( &input ) ) ); open |= ( event == FL_KEYDOWN ) && Fl::event_key( ' ' ); if( open ) { fl_cursor( FL_CURSOR_DEFAULT ); _valbox = FL_THIN_DOWN_BOX; redraw(); // remember old current group Fl_Group *c = Fl_Group::current(); // set current group to 0 so this is a top level popup window Fl_Group::current( 0 ); Popup *_popup = new Popup( this, _cbox, popHeight ); // show it and make FLTK send all events there value( value() ); _popup->show(); Fl::grab( *_popup ); Fl::focus( _cbox ); _popped = true; Fl::pushed( _cbox ); // wait for a selection to be made while( _popped ) Fl::wait(); // restore things and delete the popup _popup->hide(); Fl::grab( 0 ); delete _popup; Fl_Group::current( c ); Fl::focus( this ); _valbox = FL_UP_BOX; redraw(); return 1; } if( input.handle(event) ) { if( !editable() && ( event == FL_ENTER || event == FL_LEAVE ) ) fl_cursor( FL_CURSOR_DEFAULT ); return 1; } else return 0; }
/* ============================================================================ Callback for load log ============================================================================ */ static void cb_load_log(Fl_Widget* w, void* pOpaque) { Flu_File_Chooser* fc; char fc_path[256]; int count; const char *filename; VTTpddServerLog* pLog; CFileString fileStr; MString filePath; // Create chooser window to pick file strcpy(fc_path, path); strcat(fc_path,"/*.txt"); fl_cursor(FL_CURSOR_WAIT); fc = new Flu_File_Chooser(fc_path, "Text Files (*.txt)", 0, "Load Log Data From..."); fl_cursor(FL_CURSOR_DEFAULT); fc->preview(0); fc->show(); // Show Chooser window while (fc->visible()) Fl::wait(); count = fc->count(); if (count == 0) { delete fc; return; } // Get Filename filename = fc->value(); if (filename == 0) { delete fc; return; } // Check extension of filename fileStr = filename; filePath = filename; if (fileStr.Ext() == "") filePath += (char *) ".txt"; // Copy the new root pLog = (VTTpddServerLog *) pOpaque; if (pLog == NULL) pLog = gpLog; if (pLog == NULL) pLog = gpLog; pLog->LoadFile((const char *) filePath); delete fc; }
// Change mouse cursor to different type void Fl_Table::change_cursor(Fl_Cursor newcursor) { if ( newcursor != _last_cursor ) { fl_cursor(newcursor, FL_BLACK, FL_WHITE); _last_cursor = newcursor; } }
int gResizerBar::handle(int e) { int ret = 0; int this_y = Fl::event_y_root(); switch (e) { case FL_FOCUS: ret = 1; break; case FL_ENTER: ret = 1; fl_cursor(FL_CURSOR_NS); break; case FL_LEAVE: ret = 1; fl_cursor(FL_CURSOR_DEFAULT); break; case FL_PUSH: ret = 1; last_y = this_y; break; case FL_DRAG: HandleDrag(this_y-last_y); last_y = this_y; ret = 1; break; default: break; } return(Fl_Box::handle(e) | ret); }
int gAction::handle(int e) { /* ret = 0 sends the event to the parent window. */ int ret = 0; switch (e) { case FL_ENTER: { selected = true; ret = 1; redraw(); break; } case FL_LEAVE: { fl_cursor(FL_CURSOR_DEFAULT, FL_WHITE, FL_BLACK); selected = false; ret = 1; redraw(); break; } case FL_MOVE: { /* handling of the two margins, left & right. 4 pixels are good enough */ if (G_Mixer.chanMode[parent->chan] == SINGLE_PRESS) { onLeftEdge = false; onRightEdge = false; if (Fl::event_x() >= x() && Fl::event_x() < x()+4) { onLeftEdge = true; fl_cursor(FL_CURSOR_WE, FL_WHITE, FL_BLACK); } else if (Fl::event_x() >= x()+w()-4 && Fl::event_x() <= x()+w()) { onRightEdge = true; fl_cursor(FL_CURSOR_WE, FL_WHITE, FL_BLACK); } else fl_cursor(FL_CURSOR_DEFAULT, FL_WHITE, FL_BLACK); } } } return ret; }
int CFLTKHyperLink::handle(int event) { switch (event) { case FL_RELEASE: do_callback(); return 1; case FL_ENTER: fl_cursor(FL_CURSOR_HAND); Fl::check(); // Update cursor return 1; case FL_LEAVE: fl_cursor(FL_CURSOR_DEFAULT); Fl::check(); // Update cursor return 1; } return Fl_Box::handle(event); }
void Flu_Button :: checkLink() { // change the cursor if the mouse is over the link // the 'hover' variable reduces the number of times fl_cursor needs to be called (since it can be expensive) if( linkBtn ) { if( Fl::event_inside( x()+labelSize[0], y()+labelSize[1], labelSize[2], labelSize[3] ) ) { //if( !hover ) fl_cursor( FL_CURSOR_HAND ); hover = true; } else { //if( hover ) fl_cursor( FL_CURSOR_DEFAULT ); hover = false; } redraw(); } }
int geResizerBar::handle(int e) { int ret = 0; int this_y; if (m_type == VERTICAL) this_y = Fl::event_y_root(); else this_y = Fl::event_x_root(); switch (e) { case FL_FOCUS: ret = 1; break; case FL_ENTER: ret = 1; fl_cursor(m_type == VERTICAL ? FL_CURSOR_NS : FL_CURSOR_WE); m_hover = true; redraw(); break; case FL_LEAVE: ret = 1; fl_cursor(FL_CURSOR_DEFAULT); m_hover = false; redraw(); break; case FL_PUSH: ret = 1; m_lastPos = this_y; break; case FL_DRAG: handleDrag(this_y-m_lastPos); m_lastPos = this_y; ret = 1; break; default: break; } return(Fl_Box::handle(e) | ret); }
void gAction::delAction() { /* if SINGLE_PRESS you must delete both the keypress and the keyrelease * actions. */ if (G_Mixer.chanMode[parent->chan] == SINGLE_PRESS) { recorder::deleteAction(parent->chan, frame_a, ACTION_KEYPRESS); recorder::deleteAction(parent->chan, frame_b, ACTION_KEYREL); } else recorder::deleteAction(parent->chan, frame_a, type); /* restore the initial cursor shape, in case you delete an action and * the double arrow (for resizing) is displayed */ fl_cursor(FL_CURSOR_DEFAULT, FL_WHITE, FL_BLACK); }
int Fl_ImageViewer::handle( int event ) { int ret = Fl_Scroll::handle( event ); static int mouse_btn; static int shift_key; static bool pushed_drag = false; static int check_x; static int check_y; static int pushed_drag_point_x; static int pushed_drag_point_y; switch( event ) { case FL_DND_ENTER: case FL_DND_DRAG: case FL_DND_RELEASE: case FL_DND_LEAVE: if ( _notifier != NULL ) { ret = 1; } else { ret = 0; } break; case FL_PASTE: if ( _notifier != NULL ) { static const char* retC = Fl::event_text(); _notifier->OnDropFile( retC ); fl_cursor( FL_CURSOR_CROSS ); ret = 1; } else { ret = 0; } break; case FL_PUSH: shift_key = Fl::event_shift(); mouse_btn = Fl::event_button(); if ( mouse_btn == FL_LEFT_MOUSE ) { if ( isdrawclickpointer == true ) { isdrawclickpointer = false; this->redraw(); } check_x = Fl::event_x() + margin_x; check_y = Fl::event_y() + margin_y; if ( ( shift_key > 0 ) && ( dispbox->image() != NULL ) ) { coordclicked_x = check_x; coordclicked_y = check_y; isdrawruler = true; } else { pushed_drag_point_x = check_x + hscrollbar.value() - x(); pushed_drag_point_y = check_y + scrollbar.value() - y(); pushed_drag = true; } } return 1; case FL_MOVE: check_x = Fl::event_x(); check_y = Fl::event_y(); if ( _notifier != NULL ) { _notifier->OnMove( check_x, check_y ); } return 1; case FL_DRAG: isdrawclickpointer = false; if ( isdrawruler == true ) { coordmoving_x = Fl::event_x(); coordmoving_y = Fl::event_y(); this->redraw(); } else if ( pushed_drag == true ) { int scl_x = hscrollbar.value(); int scl_y = scrollbar.value(); int cur_x = pushed_drag_point_x - Fl::event_x(); int cur_y = pushed_drag_point_y - Fl::event_y(); if ( cur_x < 0 ) { cur_x = 0; } if ( cur_y < 0 ) { cur_y = 0; } if ( dispbox != NULL ) { if ( dispbox->image() != NULL ) { if ( dispbox->w() > this->w() ) { if ( cur_x > ( dispbox->w() - this->w() ) ) { cur_x = dispbox->w() - this->w(); } } else { cur_x = 0; } if ( dispbox->h() > this->h() ) { if ( cur_y > ( dispbox->h() - this->h() ) ) { cur_y = dispbox->h() - this->h(); } } else { cur_y = 0; } this->scroll_to( cur_x, cur_y ); if ( _notifier != NULL ) { _notifier->OnDraged( cur_x, cur_y ); } } } } return 1; case FL_ENTER: fl_cursor( FL_CURSOR_CROSS ); return 1; case FL_LEAVE: fl_cursor( FL_CURSOR_DEFAULT ); return 1; case FL_RELEASE: shift_key = Fl::event_shift(); mouse_btn = Fl::event_button(); if ( mouse_btn == FL_LEFT_MOUSE ) { if ( isdrawruler == true ) { check_x = Fl::event_x(); check_y = Fl::event_y(); int last_x = check_x + margin_x; int last_y = check_y + margin_y; isdrawruler = false; if ( _notifier != NULL ) { _notifier->OnRuler( coordclicked_x, coordclicked_y, last_x, last_y ); } } else if ( pushed_drag == true ) { pushed_drag = false; } } else if ( mouse_btn == FL_RIGHT_MOUSE ) { if ( imgsrc != NULL ) { //check_x = Fl::event_x() - x() + margin_x; check_x = Fl::event_x() - x() - margin_x; //check_y = Fl::event_y() - y() + margin_y; check_y = Fl::event_y() - y() - margin_y; if ( check_x < 0 ) { check_x = 0; } if ( check_y < 0 ) { check_y = 0; } double f_x = double( hscrollbar.value() + check_x ) / multiplier; double f_y = double( scrollbar.value() + check_y ) / multiplier; check_x = roundl( f_x ); check_y = roundl( f_y ); if ( check_x < 0 ) { check_x = 0; } else if ( check_x >= imgsrc->w() ) { check_x = imgsrc->w(); } if ( check_y < 0 ) { check_y = 0; } else if ( check_y >= imgsrc->h() ) { check_y = imgsrc->h(); } // I don't know why it is going wrong coordination, // But it need to be doing minus 2 again for matching drawing line. coordclicked_x = Fl::event_x() + x() - margin_x - 2; coordclicked_y = Fl::event_y() + y() - margin_y - 2; isdrawclickpointer = true; this->redraw(); if ( _notifier != NULL ) { _notifier->OnRightClick( check_x, check_y); } } } return 1; } return ret; }
int Flu_Spinner::handle(int event) { int W = w()*15/100; if( W < h()/2 ) W = h()/2; int X = x()+w()-W, Y = y(); if( (align() & FL_ALIGN_INSIDE) || !_editable ) { _input.readonly( true ); _input.cursor_color( FL_WHITE ); } else { _input.readonly( false ); _input.cursor_color( FL_BLACK ); } switch( event ) { case FL_PUSH: _dragging = true; if (Fl::visible_focus() && handle(FL_FOCUS)) Fl::focus(this); _lastValue = value(); _lastY = Fl::event_y(); Fl::remove_timeout( repeat_callback, this ); if( Fl::event_inside( X, Y, W, h()/2 ) ) // up button { _pushed = true; _valbox[0] = FL_DOWN_BOX; _up = true; } if( Fl::event_inside( X, Y+h()/2, W, h()/2 ) ) // down button { _pushed = true; _valbox[1] = FL_DOWN_BOX; _up = false; } if( _pushed ) { increment_cb(); _totalTime = _initialDelay; if( _doRepeat ) Fl::add_timeout( _initialDelay, repeat_callback, this); handle_push(); take_focus(); redraw(); return 1; } break; case FL_DRAG: { // only do the dragging if the last Y differs from the current Y by more than 3 pixels if( ABS(_lastY-Fl::event_y()) < 3 ) break; _dragging = true; _pushed = false; Fl::remove_timeout( repeat_callback, this ); int oldWhen = when(); _setvalue(increment(_lastValue,(_lastY-Fl::event_y())*(Fl::event_state(FL_SHIFT|FL_CTRL|FL_ALT)?10:1))); _valbox[0] = _valbox[1] = FL_DOWN_BOX; when( oldWhen ); fl_cursor((Fl_Cursor)22); _input.redraw(); redraw(); } break; case FL_RELEASE: { bool doCB = ( ( when() & FL_WHEN_RELEASE ) || ( when() & FL_WHEN_RELEASE_ALWAYS ) ) && ( _pushed || ( _valbox[0] == FL_DOWN_BOX ^ _valbox[1] == FL_DOWN_BOX ) ); _pushed = false; _dragging = false; Fl::remove_timeout( repeat_callback, this ); _valbox[0] = _valbox[1] = FL_UP_BOX; fl_cursor(FL_CURSOR_DEFAULT); redraw(); handle_release(); if( doCB ) do_callback(); _input.take_focus(); } break; case FL_FOCUS: case FL_UNFOCUS: redraw(); _input.take_focus(); return 0; case FL_ENTER: if( Fl::event_inside( &_input ) ) return _input.handle(event); else if( active_r() ) { fl_cursor(FL_CURSOR_DEFAULT); return 1; } break; case FL_LEAVE: if( Fl::event_inside( &_input ) ) return _input.handle(event); else if( active_r() ) { fl_cursor(FL_CURSOR_DEFAULT); return 1; } break; case FL_KEYBOARD: switch( Fl::event_key() ) { case FL_Down: { int oldWhen = when(); when( FL_WHEN_CHANGED ); _setvalue(increment(value(),-1*(Fl::event_state(FL_SHIFT|FL_CTRL|FL_ALT)?10:1))); when( oldWhen ); redraw(); return 1; } case FL_Up: { int oldWhen = when(); when( FL_WHEN_CHANGED ); _setvalue(increment(value(),1*(Fl::event_state(FL_SHIFT|FL_CTRL|FL_ALT)?10:1))); when( oldWhen ); redraw(); return 1; } } break; } return _input.handle(event); }
// Event handler for the framebuffer int CqFramebuffer::handle(int event) { switch(event) { case FL_FOCUS: return 1; case FL_UNFOCUS: return 1; case FL_KEYDOWN: { boost::shared_ptr<Aqsis::CqImage>& image = m_uiImageWidget->image(); int key = Fl::event_key(); if(Fl::event_ctrl()) { switch(key) { case FL_KP + '+': incSubImage(true); return 1; case FL_KP + '-': incSubImage(false); return 1; } } else if(Fl::event_shift()) { switch(key) { case 'r': if(image) image->reloadFromFile(); return 1; } } else { switch(key) { case 'h': // 'Home' widget back to center centerImageWidget(); m_scroll->redraw(); return 1; case FL_KP + '+': incZoom(1); return 1; case FL_KP + '-': incZoom(-1); return 1; } } } break; case FL_KEYUP: break; case FL_PUSH: switch (Fl::event_button()) { case FL_MIDDLE_MOUSE: // pan m_lastPos[0] = Fl::event_x(); m_lastPos[1] = Fl::event_y(); return 1; } break; case FL_RELEASE: switch (Fl::event_button()) { case FL_MIDDLE_MOUSE: fl_cursor(FL_CURSOR_DEFAULT, FL_FOREGROUND_COLOR, FL_BACKGROUND_COLOR); return 1; } break; case FL_DRAG: switch (Fl::event_button()) { case FL_MIDDLE_MOUSE: fl_cursor(FL_CURSOR_MOVE, FL_FOREGROUND_COLOR, FL_BACKGROUND_COLOR); int dx = Fl::event_x() - m_lastPos[0]; int dy = Fl::event_y() - m_lastPos[1]; m_uiImageWidget->position(m_uiImageWidget->x() + dx, m_uiImageWidget->y()+dy); m_scroll->redraw(); m_lastPos[0] = Fl::event_x(); m_lastPos[1] = Fl::event_y(); return 1; } break; case FL_MOUSEWHEEL: { if(Fl::event_ctrl()) incSubImage(Fl::event_dy() < 0); else incZoom(-Fl::event_dy()); return 1; } break; } return Fl_Window::handle(event); }
int gWaveform::handle(int e) { int ret = 0; switch (e) { case FL_PUSH: { mouseX = Fl::event_x(); pushed = true; if (!mouseOnEnd() && !mouseOnStart()) { /* right button? show the menu. Don't set selectionA,B,etc */ if (Fl::event_button3()) { openEditMenu(); } else if (mouseOnSelectionA() || mouseOnSelectionB()) { resized = true; } else { dragged = true; selectionA = Fl::event_x() - x(); if (selectionA >= data.size) selectionA = data.size; selectionB = selectionA; selectionA_abs = absolutePoint(selectionA); selectionB_abs = selectionA_abs; } } ret = 1; break; } case FL_RELEASE: { /* don't recompute points if something is selected */ if (selectionA != selectionB) { pushed = false; dragged = false; ret = 1; break; } ///int realChanStart = chan->beginTrue; ///int realChanEnd = chan->endTrue; int realChanStart = chan->begin; int realChanEnd = chan->end; if (chanStartLit) realChanStart = absolutePoint(chanStart)*2; else if (chanEndLit) realChanEnd = absolutePoint(chanEnd)*2; glue_setBeginEndChannel((gdEditor *) window(), chan, realChanStart, realChanEnd, false); pushed = false; dragged = false; redraw(); ret = 1; break; } case FL_ENTER: { // enables FL_DRAG ret = 1; break; } case FL_LEAVE: { if (chanStartLit || chanEndLit) { chanStartLit = false; chanEndLit = false; redraw(); } ret = 1; break; } case FL_MOVE: { mouseX = Fl::event_x(); mouseY = Fl::event_y(); if (mouseOnStart()) { chanStartLit = true; redraw(); } else if (chanStartLit) { chanStartLit = false; redraw(); } if (mouseOnEnd()) { chanEndLit = true; redraw(); } else if (chanEndLit) { chanEndLit = false; redraw(); } if (mouseOnSelectionA()) { fl_cursor(FL_CURSOR_WE, FL_WHITE, FL_BLACK); } else if (mouseOnSelectionB()) { fl_cursor(FL_CURSOR_WE, FL_WHITE, FL_BLACK); } else { fl_cursor(FL_CURSOR_DEFAULT, FL_WHITE, FL_BLACK); } ret = 1; break; } case FL_DRAG: { if (chanStartLit && pushed) { chanStart += Fl::event_x() - mouseX; if (chanStart < 0) chanStart = 0; if (chanStart >= chanEnd) chanStart = chanEnd-2; redraw(); } else if (chanEndLit && pushed) { chanEnd += Fl::event_x() - mouseX; if (chanEnd >= data.size - 2) chanEnd = data.size - 2; if (chanEnd <= chanStart) chanEnd = chanStart + 2; redraw(); } /* here the mouse is on the waveform, i.e. a selection */ else if (dragged) { selectionB = Fl::event_x() - x(); if (selectionB >= data.size) selectionB = data.size; if (selectionB <= 0) selectionB = 0; selectionB_abs = absolutePoint(selectionB); redraw(); } else if (resized) { if (mouseOnSelectionA()) { selectionA = Fl::event_x() - x(); selectionA_abs = absolutePoint(selectionA); } else { selectionB = Fl::event_x() - x(); selectionB_abs = absolutePoint(selectionB); } redraw(); } mouseX = Fl::event_x(); ret = 1; break; } } return ret; }
FL_EXPORT_C(void,flc_cursor)(Fl_Cursor cursor){ fl_cursor(cursor); }
FL_EXPORT_C(void,flc_cursor_with_bg)(Fl_Cursor cursor,Fl_Color bg){ fl_cursor(cursor,bg); }
FL_EXPORT_C(void,flc_cursor_with_fg_bg)(Fl_Cursor cursore,Fl_Color fg,Fl_Color bg){ fl_cursor(cursore,fg,bg); }
int Sequence_Region::handle ( int m ) { static enum trim_e trimming; int X = Fl::event_x(); int Y = Fl::event_y(); Logger _log( this ); switch ( m ) { case FL_PUSH: { /* trimming */ if ( Fl::event_shift() && ! Fl::event_ctrl() ) { switch ( Fl::event_button() ) { case 1: trim( trimming = LEFT, X ); begin_drag( Drag( x() - X, y() - Y ) ); _log.hold(); break; case 3: trim( trimming = RIGHT, X ); begin_drag( Drag( x() - X, y() - Y ) ); _log.hold(); break; default: return 0; break; } fl_cursor( FL_CURSOR_WE ); return 1; } else if ( test_press( FL_BUTTON2 ) ) { if ( Sequence_Widget::current() == this ) { if ( selected() ) deselect(); else select(); } redraw(); return 1; } /* else if ( test_press( FL_CTRL + FL_BUTTON1 ) ) */ /* { */ /* /\* duplication *\/ */ /* fl_cursor( FL_CURSOR_MOVE ); */ /* return 1; */ /* } */ else return Sequence_Widget::handle( m ); } case FL_RELEASE: { Sequence_Widget::handle( m ); if ( trimming != NO ) trimming = NO; return 1; } case FL_DRAG: { if ( ! _drag ) { begin_drag( Drag( x() - X, y() - Y, x_to_offset( X ) ) ); _log.hold(); } /* trimming */ if ( Fl::event_shift() ) { if ( trimming ) { trim( trimming, X ); return 1; } else return 0; } return Sequence_Widget::handle( m ); } default: return Sequence_Widget::handle( m ); break; } return 0; }
int JACK_Module::handle ( int m ) { static unsigned long _event_state = 0; unsigned long evstate = Fl::event_state(); switch ( m ) { case FL_PUSH: if ( Fl::event_inside( output_connection_handle ) || Fl::event_inside( output_connection2_handle ) || Fl::event_inside( input_connection_handle ) ) { _event_state = evstate; return 1; } return Module::handle(m) || 1; case FL_RELEASE: Fl::selection_owner(0); receptive_to_drop = NULL; if ( Fl::event_inside( output_connection_handle ) || Fl::event_inside( output_connection2_handle ) || Fl::event_inside( input_connection_handle ) ) { if ( _event_state & FL_BUTTON3 ) { /* was a right click */ // TODO: Pop up connection menu. } } return Module::handle(m) || 1; case FL_DRAG: { if ( Fl::event_is_click() ) return 1; int connection_handle = -1; if ( Fl::event_inside( output_connection_handle ) ) connection_handle = 0; if ( Fl::event_inside( output_connection2_handle ) ) connection_handle = 1; if ( Fl::event_button1() && connection_handle >= 0 && ! Fl::selection_owner() ) { DMESSAGE( "initiation of drag" ); char *s = (char*)malloc(256); s[0] = 0; for ( unsigned int i = _connection_handle_outputs[connection_handle][0]; i < aux_audio_output.size() && i < _connection_handle_outputs[connection_handle][1]; ++i ) { char *s2; asprintf(&s2, "jack.port://%s\r\n", aux_audio_output[i].jack_port()->jack_name() ); s = (char*)realloc( s, strlen( s ) + strlen( s2 ) + 1 ); strcat( s, s2 ); free( s2 ); } Fl::copy(s, strlen(s) + 1, 0); Fl::selection_owner(this); free( s ); Fl::dnd(); return 1; } return 1; } /* we have to prevent Fl_Group::handle() from getting these, otherwise it will mess up Fl::belowmouse() */ case FL_MOVE: if ( Fl::event_inside( output_connection_handle ) || Fl::event_inside( output_connection2_handle ) || Fl::event_inside( input_connection_handle ) ) { fl_cursor( FL_CURSOR_HAND ); } else fl_cursor( FL_CURSOR_DEFAULT ); Module::handle(m); return 1; case FL_ENTER: case FL_DND_ENTER: Module::handle(m); return 1; case FL_LEAVE: case FL_DND_LEAVE: Module::handle(m); if ( this == receptive_to_drop ) { receptive_to_drop = NULL; redraw(); } fl_cursor( FL_CURSOR_DEFAULT ); return 1; case FL_DND_RELEASE: Fl::selection_owner(0); receptive_to_drop = NULL; redraw(); return 1; case FL_DND_DRAG: { if ( this == receptive_to_drop ) return 1; if ( aux_audio_input.size() ) { receptive_to_drop = this; redraw(); return 1; } return 0; } case FL_PASTE: { receptive_to_drop = NULL; redraw(); if ( ! Fl::event_inside( this ) ) return 0; /* NOW we get the text... */ const char *text = Fl::event_text(); DMESSAGE( "Got drop text \"%s\"",text); if ( strncmp( text, "jack.port://", strlen( "jack.port://" ) ) ) { return 0; } std::vector<std::string> port_names; char *port_name; int end; while ( sscanf( text, "jack.port://%a[^\r\n]\r\n%n", &port_name, &end ) > 0 ) { DMESSAGE( "Scanning %s", port_name ); port_names.push_back( port_name ); free(port_name ); text += end; } for ( unsigned int i = 0; i < aux_audio_input.size() && i < port_names.size(); i++) { const char *pn = port_names[i].c_str(); JACK::Port *ji = aux_audio_input[i].jack_port(); if ( ji->connected_to( pn ) ) { DMESSAGE( "Disconnecting from \"%s\"", pn ); ji->disconnect( pn ); } else { DMESSAGE( "Connecting to %s", pn ); ji->connect( pn ); } } Fl::selection_owner(0); return 1; } } return Module::handle(m); }