Esempio n. 1
0
static gint gtk_slider_button_release_callback( GtkWidget *scale,
                                                GdkEventButton * /* gdk_event */,
                                                wxSlider *win)
{
    // not scrolling any longer
    win->m_isScrolling = false;

    ProcessScrollEvent(win, wxEVT_SCROLL_THUMBRELEASE,
                       GTK_RANGE(scale)->adjustment->value);

    return FALSE;
}
Esempio n. 2
0
static void
gtk_event_after(GtkRange* range, GdkEvent* event, wxSlider* win)
{
    if (event->type == GDK_BUTTON_RELEASE)
    {
        g_signal_handlers_block_by_func(range, (gpointer) gtk_event_after, win);

        if (win->m_needThumbRelease)
        {
            win->m_needThumbRelease = false;
            ProcessScrollEvent(win, wxEVT_SCROLL_THUMBRELEASE);
        }
        // Keep slider at an integral position
        win->GTKDisableEvents();
        gtk_range_set_value(GTK_RANGE (win->m_scale), win->GetValue());
        win->GTKEnableEvents();
    }
}
Esempio n. 3
0
static void gtk_slider_callback( GtkAdjustment *adjust,
                                 SCROLLBAR_CBACK_ARG
                                 wxSlider *win )
{
    if (g_isIdle) wxapp_install_idle_handler();

    if (!win->m_hasVMT) return;
    if (g_blockEventsOnDrag) return;

    const double dvalue = adjust->value;
    const double diff = dvalue - win->m_oldPos;
    if ( AreSameAdjustValues(diff, 0) )
        return;

    wxEventType evtType;
    evtType = GtkScrollTypeToWx(GET_SCROLL_TYPE(win->m_widget));

    ProcessScrollEvent(win, evtType, dvalue);

    win->m_oldPos = dvalue;
}
Esempio n. 4
0
static void gtk_slider_callback( GtkAdjustment *adjust,
                                 SCROLLBAR_CBACK_ARG
                                 wxSlider *win )
{
    if (g_isIdle) wxapp_install_idle_handler();

    if (!win->m_hasVMT) return;
    if (g_blockEventsOnDrag) return;

    const double dvalue = adjust->value;
    const double diff = dvalue - win->m_oldPos;
    if ( AreSameAdjustValues(diff, 0) )
        return;

    wxEventType evtType;
    if ( win->m_isScrolling )
        evtType = wxEVT_SCROLL_THUMBTRACK;
    // it could seem that UP/DOWN are inversed but this is what wxMSW does
    else if ( AreSameAdjustValues(diff, adjust->step_increment) )
        evtType = wxEVT_SCROLL_LINEDOWN;
    else if ( AreSameAdjustValues(diff, -adjust->step_increment) )
        evtType = wxEVT_SCROLL_LINEUP;
    else if ( AreSameAdjustValues(diff, adjust->page_increment) )
        evtType = wxEVT_SCROLL_PAGEDOWN;
    else if ( AreSameAdjustValues(diff, -adjust->page_increment) )
        evtType = wxEVT_SCROLL_PAGEUP;
    else if ( AreSameAdjustValues(adjust->value, adjust->lower) )
        evtType = wxEVT_SCROLL_TOP;
    else if ( AreSameAdjustValues(adjust->value, adjust->upper) )
        evtType = wxEVT_SCROLL_BOTTOM;
    else
        evtType = wxEVT_NULL; // wxEVT_SCROLL_CHANGED will still be generated

    ProcessScrollEvent(win, evtType, dvalue);

    win->m_oldPos = dvalue;
}
Esempio n. 5
0
static void
gtk_value_changed(GtkRange* range, wxSlider* win)
{
    const double value = gtk_range_get_value(range);
    const double oldPos = win->m_pos;
    win->m_pos = value;

    if (!win->m_hasVMT || g_blockEventsOnDrag)
        return;

    if (win->GTKEventsDisabled())
    {
        win->m_scrollEventType = GTK_SCROLL_NONE;
        return;
    }

    wxEventType eventType = wxEVT_NULL;
    if (win->m_isScrolling)
    {
        eventType = wxEVT_SCROLL_THUMBTRACK;
    }
    else if (win->m_scrollEventType != GTK_SCROLL_NONE)
    {
        // Scroll event from "move-slider" (keyboard)
        eventType = GtkScrollTypeToWx(win->m_scrollEventType);
    }
    else if (win->m_mouseButtonDown)
    {
        // Difference from last change event
        const double diff = value - oldPos;
        const bool isDown = diff > 0;

        GtkAdjustment* adj = gtk_range_get_adjustment(range);
        if (IsScrollIncrement(gtk_adjustment_get_page_increment(adj), diff))
        {
            eventType = isDown ? wxEVT_SCROLL_PAGEDOWN : wxEVT_SCROLL_PAGEUP;
        }
        else if (wxIsSameDouble(value, 0))
        {
            eventType = wxEVT_SCROLL_PAGEUP;
        }
        else if (wxIsSameDouble(value, gtk_adjustment_get_upper(adj)))
        {
            eventType = wxEVT_SCROLL_PAGEDOWN;
        }
        else
        {
            // Assume track event
            eventType = wxEVT_SCROLL_THUMBTRACK;
            // Remember that we're tracking
            win->m_isScrolling = true;
        }
    }

    win->m_scrollEventType = GTK_SCROLL_NONE;

    // If integral position has changed
    if (wxRound(oldPos) != wxRound(value))
    {
        ProcessScrollEvent(win, eventType);
        win->m_needThumbRelease = eventType == wxEVT_SCROLL_THUMBTRACK;
    }
}
Esempio n. 6
0
bool GUIProcessEvent( EVENT ev )
{
    gui_event   gui_ev;
    ORD         row, col;
    gui_window  *wnd;
    int         prev;
    int         diff;
    gui_ctl_id  id;
    gui_window  *menu_window;
    bool        new_curr_wnd;
    VSCREEN     *screen;

    // this is processed before all others and signals the end for all
    // GUI UI windows ( unconditional )
    if( ev == EV_KILL_UI ) {
        GUIDestroyWnd( NULL );
        return( false );
    }

    ev = MapMiddleToRight( ev );
    ev = CheckPrevEvent( ev );
    wnd = NULL;
    if( uimouseinstalled() ) {
        screen = uivmousepos( NULL, &row, &col );
        if( screen != NULL && (screen->flags & V_GUI_WINDOW) != 0 ) {
            wnd = (gui_window *)((char *)screen - offsetof( gui_window, screen ));
        }
    }
    if( GUIDoKeyboardMoveResize( ev ) ) {
        return( true );
    }
    if( MouseState == MOUSE_MOVE || MouseState == MOUSE_SIZE ) {
        if( GUIDoMoveResizeCheck( GUIMouseWnd, ev, row, col ) ) {
            MouseState = MOUSE_FREE;
            return( true );
        }
        if( GUI_WND_MINIMIZED( GUIMouseWnd ) ) {
            switch( ev ) {
            case EV_MOUSE_DCLICK :
            case EV_MOUSE_RELEASE :
            case EV_MOUSE_DRAG :
                ProcessMinimizedMouseEvent( ev, row, col );
            }
        } else {
            switch( ev ) {
            case EV_MOUSE_RELEASE :
            case EV_MOUSE_DRAG :
            case EV_MOUSE_DRAG_R :
                ProcessMouseReleaseDrag( ev, GUI_LBUTTONUP, row, col );
            }
        }
        return( true );
    }
    new_curr_wnd = SetCurrWnd( ev, wnd );
    if( GUIProcessAltMenuEvent( ev ) ) {
        return( true );
    }
    /* Only deal with press and dclick events for minimized windows.
     * All other non-menu events are ingored.
     */
    if( !IS_CTLEVENT( ev ) && ( GUICurrWnd != NULL ) && GUI_WND_MINIMIZED( GUICurrWnd ) ) {
        /* ignore event if mouse not in minimized current window */
        if( GUICurrWnd == wnd ) {
            switch( ev ) {
            case EV_MOUSE_PRESS :
            case EV_MOUSE_DCLICK :
            case EV_MOUSE_RELEASE :
                GUIMouseWnd = GUICurrWnd;
                ProcessMinimizedMouseEvent( ev, row, col );
                break;
            }
        }
        return( true );
    }
    if( !IS_CTLEVENT( ev ) && ( GUICurrWnd != NULL ) && GUIIsOpen( GUICurrWnd ) ) {
        /* see if any of the controls in the window consume the event */
        ev = GUIProcessControlEvent( GUICurrWnd, ev, row, col );
        /* See if the event is for on of the scroll bars. */
        /* Diff and prev are used if the event return is  */
        /* EV_SCROLL_HORIZONTAL or EV_SCROLL_VERTICAL.    */
        if( !new_curr_wnd || ( GUIGetWindowStyles() & ( GUI_INACT_GADGETS+GUI_INACT_SAME ) ) ) {
            ev = GUIGadgetFilter( GUICurrWnd, ev, &prev, &diff );
        }
        if( ev == EV_NO_EVENT ) {
            return( true );
        }
    }
    gui_ev = GUI_NO_EVENT;
    ev = GUIMapKeys( ev );
    switch( ev ) {
    case EV_MOUSE_DCLICK_R :
        ProcessMousePos( GUI_RBUTTONDBLCLK, row, col, wnd );
        return( true );
        break;
    case EV_MOUSE_RELEASE_R :
        ProcessMouseReleaseDrag( ev, GUI_RBUTTONUP, row, col );
        return( true );
        break;
    case EV_MOUSE_DRAG_R :
        if( GUICurrWnd != GUIMouseWnd ) {
            /* got drag without press first */
            ProcessMousePress( EV_MOUSE_PRESS_R, GUI_LBUTTONDOWN, row, col,
                               new_curr_wnd );
        }
    case EV_MOUSE_MOVE :
        ProcessMousePos( GUI_MOUSEMOVE, row, col, wnd );
        return( true );
        break;
    case EV_MOUSE_RELEASE :
        ProcessMouseReleaseDrag( ev, GUI_LBUTTONUP, row, col );
        return( true );
        break;
    case EV_MOUSE_DRAG :
        if( GUICurrWnd != GUIMouseWnd ) {
            /* got drag without press first */
            ProcessMousePress( EV_MOUSE_PRESS, GUI_LBUTTONDOWN, row, col,
                               new_curr_wnd );
        }
        ProcessMouseReleaseDrag( ev, GUI_MOUSEMOVE, row, col );
        return( true );
        break;
    case EV_MOUSE_PRESS_R :
        ProcessMousePress( ev, GUI_RBUTTONDOWN, row, col, new_curr_wnd );
        return( true );
        break;
    case EV_MOUSE_PRESS :
        ProcessMousePress( ev, GUI_LBUTTONDOWN, row, col, new_curr_wnd );
        return( true );
        break;
    case EV_MOUSE_DCLICK :
        ProcessMousePress( ev, GUI_LBUTTONDBLCLK, row, col, new_curr_wnd );
        return( true );
        break;
    case EV_NO_EVENT :
        gui_ev = GUI_NO_EVENT;
        break;
    case EV_SCROLL_UP :
    case EV_SCROLL_DOWN :
    case EV_SCROLL_PAGE_UP :
    case EV_SCROLL_PAGE_DOWN :
    case EV_SCROLL_LEFT :
    case EV_SCROLL_RIGHT :
    case EV_SCROLL_LEFT_PAGE :
    case EV_SCROLL_RIGHT_PAGE :
        if( GUICurrWnd != NULL ) {
            ProcessScrollEvent( ev );
            return( true );
        }
        break;
    case EV_SCROLL_VERTICAL :
        if( GUI_VSCROLL_EVENTS_SET( GUICurrWnd ) ) {
            DoScrollDrag( GUICurrWnd->vgadget, prev, diff );
        } else {
            GUIWholeWndDirty( GUICurrWnd );
        }
        return( true );
        break;
    case EV_SCROLL_HORIZONTAL :
        if( GUI_HSCROLL_EVENTS_SET( GUICurrWnd ) ) {
            DoScrollDrag( GUICurrWnd->hgadget, prev, diff );
        } else {
            GUIWholeWndDirty( GUICurrWnd );
        }
        return( true );
        break;
    case EV_MENU_INITPOPUP :
        ProcessInitPopupEvent();
        return( true );
        break;
#if 0
    case EV_BACKGROUND_RESIZE :
        {
            gui_window          *root;
            root = GUIGetRootWindow();
            if( root != NULL ) {
                GUIZoomWnd( root, GUI_NONE );
            }
        }
        return( true );
        break;
#endif
    default :
        if( IS_CTLEVENT( ev ) ) {
            if( !GUIMDIProcessEvent( ev ) ) {
                menu_window = GUIGetMenuWindow();
                if( menu_window != NULL ) {
                    id = EV2ID( ev );
                    GUIEVENTWND( menu_window, GUI_CLICKED, &id );
                }
            }
            return( true );
        }
        break;
    }
    if( ( GUICurrWnd != NULL ) && (gui_ev != GUI_NO_EVENT ) ) {
        GUIEVENTWND( GUICurrWnd, gui_ev, NULL );
    }
    return( true );
}