Beispiel #1
0
void WdeSetBaseObject( int menu_selection )
{
    HMENU               menu;
    OBJ_ID              obj_id;
    int                 id;
    WdeToolBar          *tbar;

    if( WdeGetNumRes() == 0 ) {
        return;
    }

    tbar = WdeControls;
    menu = WdeGetResMenuHandle();
    id = WdeGetCToolID();
    obj_id = -1;

    if( id != -1 && id != menu_selection ) {
        CheckMenuItem( menu, id, MF_BYCOMMAND | MF_UNCHECKED );
        WdeSetToolBarItemState( tbar, id, BUTTON_UP );
    }

    if( menu_selection != -1 ) {
        obj_id = WdeGetOBJIDFromMenu( menu_selection );
        if( obj_id != -1 ) {
            SetBaseObjType( obj_id );
            CheckMenuItem( menu, menu_selection, MF_BYCOMMAND | MF_CHECKED );
            WdeSetToolBarItemState( tbar, menu_selection, BUTTON_DOWN );
            WdeSetStatusText( NULL, "", true );
        }
    }
}
Beispiel #2
0
bool WdeSetStickyMode( bool mode )
{
    HMENU   menu;
    bool    old_mode;

    if( WdeGetNumRes() == 0 ) {
        return( false );
    }

    menu = WdeGetResMenuHandle();

    old_mode = WdeStickyMode;

    WdeStickyMode = mode;

    if( WdeStickyMode ) {
        WdeSetToolBarItemState( WdeControls, IDM_STICKY_TOOLS, BUTTON_DOWN );
        CheckMenuItem( menu, IDM_STICKY_TOOLS, MF_BYCOMMAND | MF_CHECKED );
    } else {
        WdeSetToolBarItemState( WdeControls, IDM_STICKY_TOOLS, BUTTON_UP );
        CheckMenuItem( menu, IDM_STICKY_TOOLS, MF_BYCOMMAND | MF_UNCHECKED );
    }

    WdeSetStatusText( NULL, "", true );

    return( old_mode );
}
Beispiel #3
0
Bool WdeInitHints( void )
{
    Bool ret;

    ret = TRUE;

    if( !WdeIsDDE() ) {
        ret = WdeCreateWdePopupListItem( 4, WdeGetInitialMenuHandle(),
                                         WdeInitialPopupHints );
    }

    if( ret ) {
        if( WdeIsDDE() ) {
            ret = WdeCreateWdePopupListItem( 10, WdeGetResMenuHandle(),
                                             WdeDDEPopupHints );
        } else {
            ret = WdeCreateWdePopupListItem( 10, WdeGetResMenuHandle(),
                                             WdeResPopupHints );
        }
    }

    return( ret );
}
Beispiel #4
0
void WdeShowRibbon( void )
{
    bool        created;
    char        *mtext;

    if( WdeRibbonHeight != 0 ) {
        ShowWindow( WdeRibbon->win, SW_HIDE );
        WdeRibbonHeight = 0;
        WdeResizeWindows();
        mtext = WdeAllocRCString( WDE_SHOWTOOLBAR );
    } else {
        if( WdeRibbon == NULL ) {
            WdeCreateRibbon( WdeGetMainWindowHandle() );
            created = TRUE;
        } else {
            created = FALSE;
        }
        if( !created ) {
            WdeRibbonHeight = 2 * WdeRibbonInfo->dinfo.border_size.y +
                              WdeRibbonInfo->dinfo.button_size.y +
                              2 * GetSystemMetrics( SM_CYBORDER );
            WdeResizeWindows();
        }
        mtext = WdeAllocRCString( WDE_HIDETOOLBAR );
        ShowWindow( WdeRibbon->win, SW_SHOW );
    }

    WdeSetOption( WdeOptIsRibbonVisible, WdeRibbonHeight != 0 );

    ModifyMenu( WdeGetInitialMenuHandle(), IDM_SHOW_RIBBON,
                MF_BYCOMMAND | MF_STRING, IDM_SHOW_RIBBON, mtext );
    ModifyMenu( WdeGetResMenuHandle(), IDM_SHOW_RIBBON,
                MF_BYCOMMAND | MF_STRING, IDM_SHOW_RIBBON, mtext );

    if( mtext != NULL ) {
        WdeFreeRCString( mtext );
    }
}
Beispiel #5
0
int WdeGetCToolID( void )
{
    HMENU       menu;
    UINT        state;
    int         i;

    if( WdeControls == NULL ) {
        return( 0 );
    }

    menu = WdeGetResMenuHandle();

    for( i = 0; i < NUM_TOOLS; i++ ) {
        if( WdeControlBits[i].obj_id != -1 ) {
            state = GetMenuState( menu, WdeControlBits[i].id, MF_BYCOMMAND );
            if( state != -1 && (state & MF_CHECKED) ) {
                return( WdeControlBits[i].id );
            }
        }
    }

    return( -1 );
}
Beispiel #6
0
static bool wdeControlsHook( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
    MINMAXINFO          *minmax;
    WdeToolBar          *tbar;
    OBJ_ID              obj_id;
    WORD                id;
    char                *text;
    OBJPTR              obj;
    WdeOrderMode        mode;
    ctl_id              cid;
    bool                ignore_msg;
    bool                ret;

    ignore_msg = FALSE;

    if( WdeGetNumRes() && !WdeInCleanup() ) {
        obj = WdeGetCurrentDialog();
        if( obj != NULL && Forward( obj, GET_ORDER_MODE, &mode, NULL ) && mode != WdeSelect ) {
            ignore_msg = TRUE;
        }
    }

    if( !ignore_msg && WdeGetTestMode() ) {
        ignore_msg = TRUE;
    }

    if( ignore_msg ) {
        switch( msg ) {
        case WM_RBUTTONDOWN:
        case WM_RBUTTONDBLCLK:
        case WM_LBUTTONDOWN:
        case WM_LBUTTONDBLCLK:
        case WM_RBUTTONUP:
        case WM_LBUTTONUP:
            return( true );
        }
    }

    if( (tbar = WdeControls) == NULL ) {
        if( msg == WM_GETMINMAXINFO ) {
            minmax = (MINMAXINFO *)lParam;
            minmax->ptMinTrackSize.x = 8;
        }
        return( false );
    }

    ret = false;

    switch( msg ) {
    case WM_USER:
        if( WdeGetNumRes() ) {
            obj_id = GetBaseObjType();
            id = WdeGetMenuFromOBJID( obj_id );
            if( id == wParam || (wParam == IDM_STICKY_TOOLS && WdeStickyMode) ) {
                lParam = !lParam;
            }
            WdeHandleStickyToolPress( tbar, wParam, lParam );
        }
        break;

    case WM_RBUTTONDOWN:
    case WM_RBUTTONDBLCLK:
    case WM_LBUTTONDOWN:
    case WM_LBUTTONDBLCLK:
        if( FindToolIDAtPoint( tbar->tbar, wParam, lParam, &cid ) ) {
            if( cid == IDM_CUSTOM1_TOOL ) {
                ret = !WdeIsCurrentCustControlSet( 0 );
            } else if( cid == IDM_CUSTOM2_TOOL ) {
                ret = !WdeIsCurrentCustControlSet( 1 );
            }
        }
        break;

    case WM_SIZE:
        if ( wParam != SIZE_MAXIMIZED && wParam != SIZE_MINIMIZED ) {
            GetWindowRect( hwnd, &tbar->last_pos );
        }
        break;

    case WM_MOVE:
        if( !IsZoomed( hwnd ) ) {
            GetWindowRect( hwnd, &tbar->last_pos );
        }
        break;

    case WM_GETMINMAXINFO:
        if( GetModuleHandle( "COMCTL32.DLL" ) == NULL ) {
            minmax = (MINMAXINFO *)lParam;
            minmax->ptMinTrackSize.x =
                2 * GetSystemMetrics( SM_CXFRAME ) +
                tbar->info->dinfo.border_size.x +
                tbar->info->dinfo.button_size.x - 1;
            minmax->ptMinTrackSize.y =
                2 * GetSystemMetrics( SM_CYFRAME ) +
                GetSystemMetrics(SM_CYCAPTION) +
                tbar->info->dinfo.border_size.y +
                tbar->info->dinfo.button_size.y - 1;
            ret = true;
        }
        break;

    case WM_CLOSE:
        WdeDestroyControls();
        WdeSetOption ( WdeOptIsCntlsTBarVisible, FALSE );
        ret = true;
        break;

    case WM_DESTROY:
        WdeControls = NULL;
        WdeSetCntlTBarPosOption( &tbar->last_pos );
        text = WdeAllocRCString( WDE_SHOWTOOLBOX );
        ModifyMenu( WdeGetResMenuHandle(), IDM_SHOW_TOOLS,
                    MF_BYCOMMAND | MF_STRING, IDM_SHOW_TOOLS, text );
        ModifyMenu( WdeGetInitialMenuHandle(), IDM_SHOW_TOOLS,
                    MF_BYCOMMAND | MF_STRING, IDM_SHOW_TOOLS, text );
        if( text != NULL ) {
            WdeFreeRCString( text );
        }
        WdeCloseToolBar( tbar );
        break;

    }

    return( ret );
}
Beispiel #7
0
bool WdeCreateControlsToolBar( void )
{
    RECT        t, r, screen;
    HWND        parent;
    int         id;
    char        *text;

    if( WdeControls != NULL ) {
        return ( true );
    }

    WdeSetStatusText( NULL, "", false );
    WdeSetStatusByID( WDE_CREATINGTOOLBOX, 0 );

    parent = WdeGetMainWindowHandle();

    WdeGetCntlTBarPosOption( &t );

    if( t.left == t.right && t.top == t.bottom ) {
        GetWindowRect( parent, &r );
#ifdef __NT__
        if( GetModuleHandle( "COMCTL32.DLL" ) == NULL ) {
#endif
            t.left = r.right - CONTROLS_DEFX;
            t.top = r.top + CONTROLS_INSET;
            t.right = r.right;
            t.bottom = t.top + CONTROLS_DEFY;
#ifdef __NT__
        } else {
            t.left = r.right - CONTROLS_DEFXCC;
            t.top = r.top + CONTROLS_INSET;
            t.right = r.right;
            t.bottom = t.top + CONTROLS_DEFYCC;
        }
#endif
    }

    GetWindowRect( GetDesktopWindow(), &screen );
    if( !IntersectRect( &r, &screen, &t ) ) {
        r.right = t.right - t.left;
        r.bottom = t.bottom - t.top;
        r.left = 0;
        if( screen.right > r.right )
            r.left = ( screen.right - r.right ) / 2;
        r.top = 0;
        if( screen.bottom - screen.top - r.bottom  > 0 )
            r.top = ( screen.bottom - screen.top - r.bottom ) / 2;
        r.right += r.left;
        r.bottom += r.top;
        t = r;
    }

    WdeControlsInfo->dinfo.area = t;

    WdeControls = WdeCreateToolBar( WdeControlsInfo, parent );

    if( WdeControls == NULL ) {
        return( false );
    }

    text = WdeAllocRCString( WDE_TOOLBOXCAPTION );
    SendMessage( WdeControls->win, WM_SETTEXT, 0, (LPARAM)(LPCSTR)text );
    if( text != NULL ) {
        WdeFreeRCString( text );
    }

    text = WdeAllocRCString( WDE_HIDETOOLBOX );
    ModifyMenu ( WdeGetInitialMenuHandle(), IDM_SHOW_TOOLS,
                 MF_BYCOMMAND | MF_STRING, IDM_SHOW_TOOLS, text );
    ModifyMenu ( WdeGetResMenuHandle(), IDM_SHOW_TOOLS,
                 MF_BYCOMMAND | MF_STRING, IDM_SHOW_TOOLS, text );
    if( text != NULL ) {
        WdeFreeRCString( text );
    }

    if( WdeGetNumRes() ) {
        id = WdeGetMenuFromOBJID( GetBaseObjType() );
        if( id != -1 ) {
            WdeSetToolBarItemState( WdeControls, id, BUTTON_DOWN );
        }
        WdeSetStickyMode( WdeStickyMode );
    }

    WdeSetStatusReadyText();

    return( true );
}