Esempio n. 1
0
bool GUIXCloseToolBar( gui_window *wnd )
{
    int         i;
    bool        switching;
    toolbarinfo *tbar;

    if( wnd->tbinfo == NULL ) {
        return( true );
    }
    tbar = wnd->tbinfo;
    switching = tbar->switching;
    if( tbar->fixed ) {
        for( i = 0; i < tbar->num_items; i++ ) {
            GUIDeleteToolbarMenuItem( wnd, tbar->info[i].id );
        }
    } else {
        if( tbar->floattoolbar != NULL ) {
            GUIDestroyWnd( tbar->floattoolbar );
        }
    }
    if( ( tbar->info != NULL ) && !switching ) {
        for( i = 0; i < tbar->num_items; i++ ) {
            GUIMemFree( (void *)tbar->info[i].label );
        }
        GUIMemFree( tbar->info );
        GUIMemFree( tbar );
        wnd->tbinfo = NULL;
    }
    if( !switching ) {
        GUIEVENTWND( wnd, GUI_TOOLBAR_DESTROYED, NULL );
    }
    return( true );
}
Esempio n. 2
0
void GUIDestroyWnd( gui_window *wnd )
{
    HWND        hwnd;
    gui_window  *curr;

    if( wnd == NULL ) {
        curr = GUIGetFront();
        while( curr != NULL ) {
            if( curr->flags & DOING_CLOSE ) {
                curr = GUIGetNextWindow( curr );
            } else if( _wpi_getparent( GUIGetParentFrameHWND( curr ) ) == HWND_DESKTOP ) {
                GUIDestroyWnd( curr );
                curr = GUIGetFront();
            } else {
                curr = GUIGetNextWindow( curr );
            }
        }
    } else {
        if ( GUIIsOpen( wnd ) ) {
            /* this will make a new window be chosen as current if this
             * window was current */
            hwnd = GUIGetParentFrameHWND( wnd );
            wnd->flags |= DOING_CLOSE;
            if( NumWindows == 1 || ( _wpi_getparent( hwnd ) == HWND_DESKTOP ) &&
                !( wnd->style & GUI_POPUP ) ) {
                _wpi_sendmessage( hwnd, WM_CLOSE, 0, 0 );
            } else {
                DestroyWindow( hwnd );
            }
        }
    }
}
Esempio n. 3
0
static bool CreateFloatingToolbar( gui_window *wnd, gui_ord height )
{
    gui_text_metrics    metrics;
    int                 i;
    int                 loc;
    gui_rect            client;
    gui_rect            size;
    toolbarinfo         *tbar;
    gui_colour_set      *plain;
    gui_colour_set      *standout;

    tbar = wnd->tbinfo;
    tbar->fixed = false;
    GUIGetTextMetrics( wnd, &metrics );
    if( height == 0 ) {
        height = 2 * metrics.avg.y;
    }
    height += 2 * metrics.avg.y;
    GUIGetClientRect( wnd, &size );
    FloatingToolbar.parent = wnd;
    FloatingToolbar.title = LIT( Floating_Toolbar );
    FloatingToolbar.menu->label = LIT( XFix_Toolbar );
    FloatingToolbar.menu->hinttext = LIT( Fix_Toolbar_Hint );
    FloatingToolbar.rect.height = height;
    FloatingToolbar.rect.width = size.width;
    FloatingToolbar.num_attrs = GUIGetNumWindowColours( wnd );
    FloatingToolbar.colours = GUIGetWindowColours( wnd );
    FloatingToolbar.colours[GUI_FRAME_INACTIVE] = FloatingToolbar.colours[GUI_FRAME_ACTIVE];
    tbar->floattoolbar = GUICreateWindow( &FloatingToolbar );
    GUIMemFree( FloatingToolbar.colours );
    FloatingToolbar.colours = NULL;
    Button.parent = tbar->floattoolbar;
    loc = 0;
    if( tbar->has_colours ) {
        plain = &tbar->plain;
        standout = &tbar->standout;
    } else {
        plain = NULL;
        standout = NULL;
    }
    for( i = 0; i < tbar->num_items; i++ ) {
        Button.text = tbar->info[i].label;
        Button.id = tbar->info[i].id;
        Button.rect.x = loc;
        Button.rect.width = ( strlen( Button.text ) + 4 ) * metrics.avg.x;
        Button.rect.height = metrics.avg.y * 2;
        loc += Button.rect.width;
        if( !GUIAddControl( &Button, plain, standout ) ) {
            GUIDestroyWnd( tbar->floattoolbar );
            return( false );
        }
    }
    GUIGetClientRect( tbar->floattoolbar, &client );
    GUIGetRect( tbar->floattoolbar, &size );
    size.width += loc - client.width;
    GUIResizeWindow( tbar->floattoolbar, &size );
    GUIShowWindow( tbar->floattoolbar );
    return( true );
}
Esempio n. 4
0
extern void WndClose( a_window *wnd )
{
    bool        old;

    old = WndDoingRefresh; // doing refresh during destroy message mucks PM up
    WndDoingRefresh = true;
    GUIDestroyWnd( wnd->gui );
    WndDoingRefresh = old;
}
Esempio n. 5
0
void GUIDestroyAllPopupsWithNoParent( void )
{
    gui_window  *wnd;

    wnd = GUIFindFirstPopupWithNoParent();
    while( wnd ) {
        GUIDestroyWnd( wnd );
        wnd = GUIFindFirstPopupWithNoParent();
    }
}
Esempio n. 6
0
void GUIDestroyAllChildren( gui_window *parent )
{
    gui_window  *wnd;

    GUIMarkChildrenWithFlag( parent, DOING_DESTROY );
    wnd = GUIFindFirstChild( parent );
    while( wnd ) {
        wnd->flags |= UTILITY_BIT;
        GUIDestroyWnd( wnd );
        wnd = GUIFindFirstChild( parent );
    }
}
Esempio n. 7
0
void StatusFini( void )
/*********************/
{
    if( StatusWnd == NULL ){
        return;
    } else {
        if( StatusInfo.title != NULL ) {
            GUIMemFree( (void *)StatusInfo.title );
        }
        GUIDestroyWnd( StatusWnd );
        StatusWnd = NULL;
    }
}
Esempio n. 8
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 );
}