Esempio n. 1
0
/*
 * CreateSpyTool - create the spy toolbar
 */
void CreateSpyTool( HWND parent )
{
    TOOLDISPLAYINFO     dinfo;
    RECT                r;
    int                 i;

    GetClientRect( parent, &r );
    r.bottom = r.top + GET_TOOLBAR_HEIGHT( BITMAP_Y );

    memset( &dinfo, 0, sizeof( dinfo ) );
    dinfo.button_size.x = BITMAP_X;
    dinfo.button_size.y = BITMAP_Y;
    dinfo.border_size.x = BORDER_X( BITMAP_X );
    dinfo.border_size.y = BORDER_Y( BITMAP_Y );
    dinfo.style = TOOLBAR_FIXED_STYLE;
    dinfo.is_fixed = TRUE;
    dinfo.area = r;
    dinfo.hook = MyToolBarProc;
    dinfo.helphook = spyToolBarHint;
    dinfo.background = NULL;
    dinfo.use_tips = TRUE;
    toolBar = ToolBarInit( parent );

    ToolBarDisplay( toolBar, &dinfo );

    for( i = 0; i < sizeof( toolList ) / sizeof( button ); i++ ) {
        addToolButton( &toolList[i] );
    }

    ShowWindow( ToolBarWindow( toolBar ), SW_SHOWNORMAL );
    UpdateWindow( ToolBarWindow( toolBar ) );

} /* CreateSpyTool */
Esempio n. 2
0
/*
 * ShowSpyTool - show or hide toolbar
 */
void ShowSpyTool( BOOL show )
{
    if( show ) {
        ShowWindow( ToolBarWindow( toolBar ), SW_SHOW );
    } else {
        ShowWindow( ToolBarWindow( toolBar ), SW_HIDE );
    }

} /* ShowSpyTool */
Esempio n. 3
0
static void newToolBarWindow( void )
{
    RECT                rect;
    POINT               tl;
    int                 height, width;
    TOOLDISPLAYINFO     dinfo;

    userClose = false;

    GetWindowRect( edit_container_id, &rect );
    width = rect.right - rect.left;
    height = rect.bottom - rect.top;

    tl.x = rect.left;
    tl.y = 0;
    ScreenToClient( root_window_id, &tl );

    if( fixedToolBar ) {
        // make it float
        tl.y = 0;
        height += (fixedRect.bottom - fixedRect.top) + 1;
        dinfo.area = ToolBarFloatRect;
        dinfo.style = TOOLBAR_FLOAT_STYLE;
        dinfo.is_fixed = false;
    } else {
//      tl.y = fixedRect.bottom + 1;
//      height -= (fixedRect.bottom - fixedRect.top) + 1;
        tl.y = fixedRect.bottom;
        height -= (fixedRect.bottom - fixedRect.top);
        dinfo.area = fixedRect;
        dinfo.style = TOOLBAR_FIXED_STYLE;
        dinfo.is_fixed = true;
    }
    dinfo.button_size.x = ToolBarButtonWidth;
    dinfo.button_size.y = ToolBarButtonHeight;
    dinfo.border_size.x = BORDER_X( ToolBarButtonWidth );
    dinfo.border_size.y = BORDER_Y( ToolBarButtonHeight );
    dinfo.background = buttonPattern;
    dinfo.hook = myToolBarProc;
    dinfo.helphook = toolBarHelp;

    ToolBarDisplay( toolBar, &dinfo );

    MoveWindow( edit_container_id, tl.x, tl.y, width, height, TRUE );
    ShowWindow( ToolBarWindow( toolBar ), SW_SHOWNORMAL );
    UpdateWindow( ToolBarWindow( toolBar ) );
    fixedToolBar = !fixedToolBar;

    userClose = true;

} /* newToolBarWindow */
Esempio n. 4
0
void GUIResizeToolBar( gui_window *wnd )
{
    WPI_RECT    rect;
    GUI_RECTDIM left, top, right, bottom;
    GUI_RECTDIM height;
    GUI_RECTDIM t, h;
    toolbarinfo *tbar;

    tbar = wnd->tbinfo;
    if( tbar != NULL ) {
        rect = wnd->root_client_rect;
        if( wnd->root == NULLHANDLE ) {
            rect = wnd->hwnd_client_rect;
        }
        _wpi_rationalize_rect( &rect );
        if( tbar->info.is_fixed ) {
            height = _wpi_getheightrect( tbar->fixedrect );
            h = _wpi_getheightrect( rect );
            _wpi_getrectvalues( rect, &left, &top, &right, &bottom );
            t = _wpi_cvth_y_plus1( top, h );
            bottom = _wpi_cvth_y_plus1( height, h );
            _wpi_setwrectvalues( &tbar->fixedrect, left, t, right, bottom );
            t = _wpi_cvth_y_size_plus1( top, h, height );
            _wpi_movewindow( ToolBarWindow( tbar->hdl ), left, t, right - left, height, TRUE );
        }
    }
}
Esempio n. 5
0
/*
 * ResizeSpyTool - resize toolbar
 */
void ResizeSpyTool( WORD width, WORD height )
{
    height = height;
    MoveWindow( ToolBarWindow( toolBar ), 0, 0, width,
                GET_TOOLBAR_HEIGHT( BITMAP_Y ), TRUE );

} /* ResizeSpyTool */
Esempio n. 6
0
WREToolBar *WRECreateToolBar( WREToolBarInfo *info, HWND parent )
{
    WREToolBar  *tbar;
    int         i;
    HMENU       sys_menu;
    char        *text;

    if( info == NULL ) {
        return( NULL );
    }

    tbar = WREAllocToolBar();
    if( tbar == NULL ) {
        return( NULL );
    }

    tbar->info = info;
    tbar->parent = parent;
    tbar->tbar = (toolbar)ToolBarInit( parent );

    ToolBarDisplay( tbar->tbar, &info->dinfo );

    for( i = 0; i < info->num_items; i++ ) {
        ToolBarAddItem( tbar->tbar, &info->items[i] );
    }

    tbar->win = ToolBarWindow( tbar->tbar );

    if( (info->dinfo.style & TOOLBAR_FLOAT_STYLE) == TOOLBAR_FLOAT_STYLE ) {
        sys_menu = GetSystemMenu( tbar->win, FALSE );
        i = GetMenuItemCount( sys_menu );
        for( ; i > 0; i-- ) {
            DeleteMenu( sys_menu, i, MF_BYPOSITION );
        }
        text = WREAllocRCString( WRE_SYSMENUMOVE );
        AppendMenu( sys_menu, MF_STRING, SC_MOVE, text != NULL ? text : "Move" );
        if( text != NULL ) {
            WREFreeRCString( text );
        }
        text = WREAllocRCString( WRE_SYSMENUSIZE );
        AppendMenu( sys_menu, MF_STRING, SC_SIZE, text != NULL ? text : "Size" );
        if( text != NULL ) {
            WREFreeRCString( text );
        }
        text = WREAllocRCString( WRE_SYSMENUHIDE );
        AppendMenu( sys_menu, MF_STRING, SC_CLOSE, text != NULL ? text : "Hide" );
        if( text != NULL ) {
            WREFreeRCString( text );
        }
    }

    ShowWindow( tbar->win, SW_SHOWNORMAL );

    UpdateWindow( tbar->win );

    WREAddToolBar( tbar );

    return( tbar );
}
Esempio n. 7
0
static bool IsToolBarCommand( gui_window *wnd, WPI_PARAM1 wparam, WPI_PARAM2 lparam )
{
#ifdef __NT__
    return( wnd != NULL && wnd->toolbar != NULL && wnd->toolbar->hdl != NULL &&
            GET_WM_COMMAND_HWND( wparam, lparam ) == ToolBarWindow( wnd->toolbar->hdl ) );
#else
    return( FALSE );
#endif
}
Esempio n. 8
0
/*
 * AddBitmapToToolBar - add a toolbar item ([temp], bitmap, help & command)
 */
vi_rc AddBitmapToToolBar( const char *data )
{
    char                file[FILENAME_MAX];
    char                help[MAX_STR];
    char                dont_save[MAX_STR];
    tool_item           *item;
    int                 cmd_len;
    int                 name_len;

    dont_save[0] = 0;

    data = SkipLeadingSpaces( data );
    if( strnicmp( data, "temp", 4 ) == 0 ) {
        /* get to the command */
        GetStringWithPossibleQuote( &data, dont_save );
    }

    GetStringWithPossibleQuote( &data, file );
    GetStringWithPossibleQuote( &data, help );

    data = SkipLeadingSpaces( data );
    cmd_len = strlen( data );
    name_len = strlen( file );
    item = MemAlloc( sizeof( tool_item ) + cmd_len + name_len + strlen( help ) + 2 );
    strcpy( item->cmd, data );
    if( name_len != 0 ) {
        item->id = NextMenuId();
    } else {
        item->is_blank = true;
    }
    item->dont_save = ( strlen( dont_save ) != 0 );

    if( file[0] && item->cmd[0] ) {
        item->bmp = LoadBitmap( InstanceHandle, file );
        if( item->bmp == HNULL ) {
            item->bmp = ReadBitmapFile( ToolBarWindow( toolBar ), file, NULL );
        }
        item->name = &item->cmd[cmd_len + 1];
        strcpy( item->name, file );
        item->help = &item->name[name_len + 1];
        strcpy( item->help, help );
    } else {
        item->bmp = HNULL;
    }
    if( toolBar ) {
        addToolBarItem( item );
    }
    AddLLItemAtEnd( &toolBarHead, &toolBarTail, &item->tool_head );
    return( ERR_NO_ERR );

} /* AddBitmapToToolBar */
Esempio n. 9
0
/*
 * createToolBar - create the tool bar
 */
static void createToolBar( RECT *rect )
{
    int                 toolbar_height;
    TOOLDISPLAYINFO     dinfo;

    fixedToolBar = true;
    dinfo.button_size.x = EditVars.ToolBarButtonWidth;
    dinfo.button_size.y = EditVars.ToolBarButtonHeight;
    dinfo.border_size.x = BORDER_X( EditVars.ToolBarButtonWidth );
    dinfo.border_size.y = BORDER_Y( EditVars.ToolBarButtonHeight );
    dinfo.style = TOOLBAR_FIXED_STYLE;
    dinfo.is_fixed = true;
    toolbar_height = TOOLBAR_HEIGHT( EditVars.ToolBarButtonHeight );
    dinfo.area = *rect;
    dinfo.area.bottom = ((dinfo.area.top + toolbar_height + 1) & ~1) - 1;
    dinfo.area.top -= 1;
    dinfo.area.bottom -= 1;
    dinfo.area.left -= 1;
    dinfo.area.right += 1;
    dinfo.hook = myToolBarProc;
    dinfo.helphook = toolBarHelp;
    dinfo.background = LoadBitmap( InstanceHandle, "BUTTONPATTERN" );
    dinfo.use_tips = 1;
    buttonPattern = dinfo.background;
    toolBar = ToolBarInit( root_window_id );
#if defined( __NT__ )
    ToolBarChangeSysColors( GetSysColor( COLOR_BTNFACE ),
#else
    ToolBarChangeSysColors( GetRGB( EditVars.ToolBarColor ),
#endif
                            GetSysColor( COLOR_BTNHIGHLIGHT ),
                            GetSysColor( COLOR_BTNSHADOW ) );
    ToolBarDisplay( toolBar, &dinfo );
    if( toolBar != NULL ) {
        // CopyRect( &fixedRect, &dinfo.area );
        // WARNING: These are some pretty stupid arbitrary constants here
        rect->top = dinfo.area.bottom;
        ShowWindow( ToolBarWindow( toolBar ), SW_SHOWNORMAL );
        // UpdateWindow( ToolBarWindow( toolBar ) );
    }

} /* createToolBar */
Esempio n. 10
0
bool GUIChangeToolBar( gui_window *wnd )
{
    gui_event   gui_ev;
    toolbarinfo *tbar;
    HWND        toolhwnd;
    int         t;
    GUI_RECTDIM left, top, right, bottom;

    tbar = wnd->tbinfo;
    if( !tbar->info.is_fixed ) {
        tbar->info.is_fixed = true;
        tbar->info.style = TOOLBAR_FIXED_STYLE;
        tbar->info.area = tbar->fixedrect;
        gui_ev = GUI_TOOLBAR_FIXED;
    } else {
        tbar->info.is_fixed = false;
        tbar->info.style = TOOLBAR_FLOAT_STYLE;
        tbar->info.area = tbar->floatrect;
        _wpi_cvtc_rect_plus1( wnd->root, &tbar->info.area );
        gui_ev = GUI_TOOLBAR_FLOATING;
    }
    ToolBarDisplay( tbar->hdl, &tbar->info );
    if( tbar->info.style != TOOLBAR_FLOAT_STYLE ) {
        ToolBarRedrawButtons( tbar->hdl );
    }
    toolhwnd = ToolBarWindow( tbar->hdl );
    if( tbar->info.style == TOOLBAR_FLOAT_STYLE ) {
        _wpi_getrectvalues( tbar->floatrect, &left, &top, &right, &bottom );
        t = top;
        //t = _wpi_cvtc_y_size( wnd->hwnd, t, bottom - top );
        t = _wpi_cvtc_y_plus1( wnd->root, t );
        _wpi_movewindow( toolhwnd, left, t, right-left, bottom-top, TRUE );
    }
    GUIResizeBackground( wnd, true );
    _wpi_showwindow( toolhwnd, SW_SHOWNORMAL );
    _wpi_updatewindow( toolhwnd );
    GUIEVENTWND( wnd, gui_ev, NULL );
    return( true );
}
Esempio n. 11
0
/*
 * addToolBarItem - add an item to the tool bar
 */
static void addToolBarItem( tool_item *item )
{
    TOOLITEMINFO        info;
    int                 id;

    if( item->is_blank ) {
        info.u.blank_space = 8;
        info.flags = ITEM_BLANK;
    } else {
        info.id = item->id;
        info.u.bmp = item->bmp;
        info.flags = 0;
    }
    id = getTip( item->name );
    if( id >= 0 ) {
        LoadString( InstanceHandle, id, info.tip, MAX_TIP );
    } else {
        info.tip[0] = '\0';
    }
    info.depressed = false;
    ToolBarAddItem( toolBar, &info );
    InvalidateRect( ToolBarWindow( toolBar ), NULL, FALSE );

} /* addToolBarItem */
Esempio n. 12
0
WdeToolBar *WdeCreateToolBar( WdeToolBarInfo *info, HWND parent )
{
    WdeToolBar  *tbar;
    int         i;
    int         width;
    int         height;
    HMENU       sys_menu;
    char        *text;

    if( info == NULL ) {
        return( NULL );
    }

    tbar = WdeAllocToolBar();
    if( tbar == NULL ) {
        return( NULL );
    }

    tbar->last_pos = info->dinfo.area;
    tbar->info = info;
    tbar->parent = parent;
    tbar->tbar = ToolBarInit( parent );

    ToolBarDisplay( tbar->tbar, &info->dinfo );

    for( i = 0; i < info->num_items; i++ ) {
        if( info->items[i].u.bmp != (HBITMAP)NULL ) {
            ToolBarAddItem( tbar->tbar, &info->items[i] );
        }
    }

    tbar->win = ToolBarWindow( tbar->tbar );

    if( (info->dinfo.style & TOOLBAR_FLOAT_STYLE) == TOOLBAR_FLOAT_STYLE ) {
        sys_menu = GetSystemMenu( tbar->win, FALSE );
        i = GetMenuItemCount( sys_menu );
        for( ; i > 0; i-- ) {
            DeleteMenu( sys_menu, 0, MF_BYPOSITION );
        }
        text = WdeAllocRCString( WDE_SYSMENUMOVE );
        AppendMenu( sys_menu, MF_STRING, SC_MOVE, text != NULL ? text : "Move" );
        if( text != NULL ) {
            WdeFreeRCString( text );
        }
        text = WdeAllocRCString( WDE_SYSMENUSIZE );
        AppendMenu( sys_menu, MF_STRING, SC_SIZE, text != NULL ? text : "Size" );
        if( text != NULL ) {
            WdeFreeRCString( text );
        }
        text = WdeAllocRCString( WDE_SYSMENUHIDE );
        AppendMenu( sys_menu, MF_STRING, SC_CLOSE, text != NULL ? text : "Hide" );
        if( text != NULL ) {
            WdeFreeRCString( text );
        }
    }

    width = info->dinfo.area.right - info->dinfo.area.left;
    height = info->dinfo.area.bottom - info->dinfo.area.top;
    SetWindowPos( tbar->win, (HWND)NULL, 0 ,0 , width, height, SWP_NOMOVE | SWP_NOZORDER );

    ShowWindow( tbar->win, SW_SHOWNORMAL );

    UpdateWindow( tbar->win );

    WdeAddToolBar( tbar );

    return( tbar );
}
Esempio n. 13
0
bool GUIXCreateToolBarWithTips( gui_window *wnd, bool fixed, gui_ord height,
                                int num_toolbar_items, gui_toolbar_struct *toolinfo,
                                bool excl, gui_colour_set *plain,
                                gui_colour_set *standout, gui_rect *float_pos,
                                bool use_tips )
{
    gui_coord           size;
    gui_coord           pos;
    HWND                parent;
    HWND                toolhwnd;
    toolbarinfo         *tbar;
    int                 i;
    TOOLITEMINFO        info;
    int                 fixed_height;
    int                 fixed_width;
    int                 adjust_amount;
    int                 width;
    int                 new_right;
    int                 bm_h;
    int                 bm_w;
    GUI_RECTDIM         left, top, right, bottom;
    int                 h;

    excl = excl;
    plain = plain;
    standout = standout;
    fixed_height = 0;
    fixed_width = 0;
    if( ( wnd == NULL ) || ( num_toolbar_items < 1 ) || ( toolinfo == NULL ) ||
        ( wnd->hwnd == NULLHANDLE ) || ( wnd->root == NULLHANDLE ) ) {
        return( false );
    }
    if( wnd->tbinfo != NULL ) {
        GUICloseToolBar( wnd );
    }
    tbar = wnd->tbinfo = (toolbarinfo *)GUIMemAlloc( sizeof( toolbarinfo ) );
    if( tbar == NULL ) {
        return( false );
    }
    memset( tbar, 0, sizeof( toolbarinfo ) );
    parent = wnd->root;
    tbar->fixedrect = wnd->hwnd_client_rect;
    tbar->bitmaps = (HBITMAP *)GUIMemAlloc( num_toolbar_items * sizeof( HBITMAP ) );
    if( tbar->bitmaps == NULL ) {
        GUIMemFree( tbar );
        wnd->tbinfo = NULL;
        return( false );
    }
    for( i = 0; i < num_toolbar_items; i++ ) {
        tbar->bitmaps[i] = _wpi_loadbitmap( GUIResHInst,
                                _wpi_makeintresource( toolinfo[i].bitmap ) );
        if( height == 0 ) {
            _wpi_getbitmapdim( tbar->bitmaps[i], &bm_w, &bm_h );
            if( bm_h > fixed_height ) {
                fixed_height = bm_h;
            }
            if( bm_w > fixed_width ) {
                fixed_width = bm_w;
            }
        }
    }
    tbar->info.border_size.x = BORDER_AMOUNT;
    tbar->info.border_size.y = BORDER_AMOUNT;
    /* space for border and space before border */
    adjust_amount = 2*(_wpi_getsystemmetrics( SM_CYBORDER )+BORDER_AMOUNT);
    if( height == 0 ) { /* maintian # of pixels in bitmap */
        height = fixed_height + adjust_amount + OUTLINE_AMOUNT;
        width = fixed_width + OUTLINE_AMOUNT;
    } else {
        /* only height of windows given, make bitmaps square */
        size.x = 0;
        size.y = height - 2;
        GUIScaleToScreenR( &size );
        height = size.y;
        width = size.y;
    }

    _wpi_getrectvalues( tbar->fixedrect, &left, &top, &right, &bottom );
    h      = _wpi_getheightrect( tbar->fixedrect );
    bottom = _wpi_cvth_y_plus1( height, h );
    top    = _wpi_cvth_y_plus1( top, h );
    _wpi_setwrectvalues( &tbar->fixedrect, left, top, right, bottom );
    height -= adjust_amount; /* leaving just button size */
    tbar->info.button_size.x = width;
    tbar->info.button_size.y = height;
    bottom = height + BORDER_AMOUNT * 2 +
             _wpi_getsystemmetrics( SM_CYCAPTION ) +
             2 * ( _wpi_getsystemmetrics( SM_CYFRAME ) -
                   _wpi_getsystemmetrics( SM_CYBORDER ) );
    bottom = _wpi_cvth_y_plus1( bottom, h );
#ifdef __OS2_PM__
    bottom -= 2;
#endif
    new_right = width * num_toolbar_items -
                (num_toolbar_items - 1) * tbar->info.border_size.x +
                left + 2 * _wpi_getsystemmetrics( SM_CXFRAME ) +
                BORDER_AMOUNT * 2;
    if( new_right < right ) {
        right = new_right;
    }

    _wpi_setwrectvalues( &tbar->floatrect, left, top, right, bottom );
    _wpi_mapwindowpoints( parent, HWND_DESKTOP, (WPI_PPOINT)&tbar->floatrect, 2 );

    if( fixed ) {
        tbar->info.area = tbar->fixedrect;
        tbar->info.style = TOOLBAR_FIXED_STYLE;
    } else {
        if( float_pos != NULL ) {
            GUICalcLocation( float_pos, &pos, &size, parent );
            _wpi_setwrectvalues( &tbar->floatrect, pos.x, pos.y,
                                 pos.x + size.x, pos.y + size.y );
            _wpi_mapwindowpoints( parent, HWND_DESKTOP, (WPI_PPOINT)&tbar->floatrect, 2 );
        }
        tbar->info.area = tbar->floatrect;
        tbar->info.style = TOOLBAR_FLOAT_STYLE;
    }

    tbar->info.hook = guiToolBarProc;
    tbar->info.helphook = guiToolBarHelp;
    tbar->info.background = 0;
    tbar->info.foreground = 0;
    tbar->num = num_toolbar_items;
    tbar->info.is_fixed = fixed;
    tbar->info.use_tips = use_tips;

    tbar->hdl = ToolBarInit( parent );

    ToolBarDisplay( tbar->hdl, &tbar->info );

    GUIResizeBackground( wnd, true );

    for( i = 0; i < num_toolbar_items; i++ ) {
        info.u.bmp = tbar->bitmaps[i];
        info.id = toolinfo[i].id;
        info.flags = 0;
        if( use_tips && toolinfo[i].tip != NULL ) {
            strncpy( info.tip, toolinfo[i].tip, MAX_TIP );
        } else {
            info.tip[0] = '\0';
        }
        ToolBarAddItem( tbar->hdl, &info );
    }
    toolhwnd = ToolBarWindow( tbar->hdl );
    _wpi_showwindow( toolhwnd, SW_SHOWNORMAL );
    _wpi_updatewindow( toolhwnd );
    return( true );
}
Esempio n. 14
0
/*
 * GetSpyToolRect - get toolbar position and size
 */
void GetSpyToolRect( RECT *prect )
{
    GetWindowRect( ToolBarWindow( toolBar ), prect );

} /* GetSpyToolRect */
Esempio n. 15
0
/*
 * GetToolbarWindow - return the current toolbar window
 */
HWND GetToolbarWindow( void )
{
    return( ToolBarWindow( toolBar ) );

} /* GetToolbarWindow */