Beispiel #1
0
bool WDeleteEditWinLBoxEntry( WMenuEditInfo *einfo, LRESULT pos, bool free_it )
{
    HWND        lbox;
    bool        ok;
    WMenuEntry  *entry;
    LRESULT     ret;
    LRESULT     count;

    ok = ( einfo != NULL && einfo->edit_dlg != NULL );

    if( ok ) {
        lbox = GetDlgItem( einfo->edit_dlg, IDM_MENUEDLIST );
        ok = ( lbox != NULL );
    }

    if( ok ) {
        count = SendMessage( lbox, LB_GETCOUNT, 0, 0 );
        ok = ( count != 0 && count != LB_ERR && pos < count );
    }

    if( ok ) {
        entry = (WMenuEntry *)SendMessage( lbox, LB_GETITEMDATA, (WPARAM)pos, 0 );
        if( entry != NULL ) {
            if( free_it ) {
                ok = WRemoveMenuEntry( einfo->menu, entry );
                if( ok ) {
                    WFreeMenuEntries( entry->child );
                    WFreeMenuEntry( entry );
                }
            }
        } else {
            ok = false;
        }
    }

    if( ok ) {
        einfo->info->modified = true;
        if( free_it ) {
            ret = WInitEditWindowListBox( einfo );
        } else {
            ret = SendMessage( lbox, LB_DELETESTRING, (WPARAM)pos, 0 );
        }
        ok = ( ret != LB_ERR );
    }

    if( ok ) {
        einfo->current_entry = NULL;
        einfo->current_pos = LB_ERR;
        if( pos > count - 2 )
            pos = count - 2;
        ok = ( SendMessage( lbox, LB_SETCURSEL, (WPARAM)pos, 0 ) != LB_ERR );
        if( ok ) {
            WHandleSelChange( einfo );
        } else {
            WSetEditWindowControls( einfo, NULL );
        }
    }

    return( ok );
}
Beispiel #2
0
void WHandleMenuSelect( WMenuEditInfo *einfo, WPARAM wParam, LPARAM lParam )
{
    WMenuEntry  *entry;
    HWND        lbox;
    HMENU       popup;
    WORD        flags;
    WORD        id;
    int         pos;

    if( !einfo || !einfo->menu || ! einfo->menu->first_entry ) {
        return;
    }

    lbox = GetDlgItem ( einfo->edit_dlg, IDM_MENUEDLIST );
    if( lbox == (HWND)NULL ) {
        return;
    }

    flags = GET_WM_MENUSELECT_FLAGS(wParam,lParam);

    entry = NULL;

    if( ( flags == (WORD)-1 ) &&
         ( GET_WM_MENUSELECT_HMENU(wParam,lParam) == (HMENU)NULL ) ) {
        // we ignore WM_MENUSELECT when a menu is closing
    } else if( flags & MF_SYSMENU ) {
        // we ignore WM_MENUSELECT for the system menu
    } else if( flags & MF_SEPARATOR ) {
        // we ignore WM_MENUSELECT for separators, for now...
    } else if( flags & MF_POPUP ) {
        popup = (HMENU) GET_WM_MENUSELECT_ITEM(wParam,lParam);
        #ifdef __NT__
            popup = GetSubMenu( (HMENU)lParam, (int)popup );
        #endif
        entry = WFindEntryFromPreviewPopup( einfo->menu->first_entry, popup );
    } else {
        id = GET_WM_MENUSELECT_ITEM(wParam,lParam);
        entry = WFindEntryFromPreviewID( einfo->menu->first_entry, id );
    }

    if( entry == NULL ) {
        return;
    }

    pos = 0;

    if ( WFindEntryLBPos( einfo->menu->first_entry, entry, &pos ) ) {
        pos--;
        einfo->current_entry = NULL;
        einfo->current_pos   = -1;
        if( SendMessage ( lbox, LB_SETCURSEL, (WPARAM) pos, 0 ) != LB_ERR ) {
            WHandleSelChange ( einfo );
        }
    }
}
Beispiel #3
0
static void handleSymbols( WStringEditInfo *einfo )
{
    if( !WEditSymbols( einfo->win, &einfo->info->symbol_table,
                       WGetEditInstance(), WStrHelpRoutine ) ) {
        return;
    }

    WResolveStringTableSymIDs( einfo );

    WHandleSelChange( einfo );
}
Beispiel #4
0
Bool WDeleteEditWinLBoxEntry ( WAccelEditInfo *einfo, int pos, Bool free_it )
{
    HWND         lbox;
    Bool         ok;
    WAccelEntry *entry;
    LRESULT      ret, max;

    ok = ( einfo && einfo->edit_dlg );

    if ( ok ) {
        lbox = GetDlgItem ( einfo->edit_dlg, IDM_ACCEDLIST );
        ok = ( lbox != NULL );
    }

    if ( ok ) {
        ret = SendMessage ( lbox, LB_GETCOUNT, 0, 0 );
        max = ret;
        ok = ( ret && ( ret != LB_ERR ) && ( pos < (int)ret ) );
    }

    if ( ok ) {
        entry = (WAccelEntry *)
            SendMessage ( lbox, LB_GETITEMDATA, (WPARAM) pos, 0 );
        if ( entry ) {
            if ( free_it ) {
                ok = WFreeAccelTableEntry ( einfo->tbl, entry );
            }
        } else {
            ok = FALSE;
        }
    }

    if ( ok ) {
        einfo->info->modified = TRUE;
        ret = SendMessage ( lbox, LB_DELETESTRING, (WPARAM) pos, 0 );
        ok = ( ret != LB_ERR );
    }

    if ( ok ) {
        einfo->current_entry = NULL;
        einfo->current_pos   = -1;
        pos = min ( max-2, pos );
        ret = SendMessage ( lbox, LB_SETCURSEL, (WPARAM) pos, 0 );
        ok = ( ret != LB_ERR );
        if ( ok ) {
            WHandleSelChange ( einfo );
        }
    }

    return ( ok );
}
Beispiel #5
0
static void handleSymbols( WMenuEditInfo *einfo )
{
    char        *text;

    if( !WEditSymbols( einfo->win, &einfo->info->symbol_table,
                       WGetEditInstance(), WMenuHelpRoutine ) ) {
        return;
    }

    WResolveMenuSymIDs( einfo );

    text = WGetStrFromEdit( GetDlgItem( einfo->edit_dlg, IDM_MENUEDID ), NULL );
    WRAddSymbolsToComboBox( einfo->info->symbol_table, einfo->edit_dlg,
                            IDM_MENUEDID, WR_HASHENTRY_ALL );
    if( text != NULL ) {
        WSetEditWithStr( GetDlgItem( einfo->edit_dlg, IDM_MENUEDID ), text );
        WMemFree( text );
    }

    WHandleSelChange( einfo );
}
Beispiel #6
0
WINEXPORT BOOL CALLBACK WMenuEditProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
{
    WMenuEditInfo       *einfo;
    HWND                win;
    RECT                r;
    POINT               p;
    LRESULT             ret;
    WORD                wp, cmd;

    ret = FALSE;
    einfo = (WMenuEditInfo *)GET_DLGDATA( hDlg );

    switch( message ) {
    case WM_INITDIALOG:
        einfo = (WMenuEditInfo *)lParam;
        einfo->edit_dlg = hDlg;
        SET_DLGDATA( hDlg, (LONG_PTR)einfo );
        WRAddSymbolsToComboBox( einfo->info->symbol_table, hDlg,
                                IDM_MENUEDID, WR_HASHENTRY_ALL );
        ret = TRUE;
        break;

    case WM_SYSCOLORCHANGE:
        WCtl3dColorChange();
        break;

#if 0
#ifdef __NT__
    case WM_CTLCOLORBTN:
    case WM_CTLCOLORDLG:
    case WM_CTLCOLOREDIT:
    case WM_CTLCOLORLISTBOX:
    case WM_CTLCOLORMSGBOX:
    case WM_CTLCOLORSCROLLBAR:
    case WM_CTLCOLORSTATIC:
#else
    case WM_CTLCOLOR:
#endif
        return( (LRESULT)WCtl3dCtlColorEx( message, wParam, lParam ) );
#endif

    case WM_LBUTTONDBLCLK:
    case WM_RBUTTONDBLCLK:
    case WM_RBUTTONUP:
        MAKE_POINT( p, lParam );
        win = GetDlgItem( hDlg, IDM_MENUEDRNAME );
        GetWindowRect( win, &r );
        MapWindowPoints( HWND_DESKTOP, hDlg, (POINT *)&r, 2 );
        if( PtInRect( &r, p ) ) {
            WHandleRename( einfo );
        }
        ret = TRUE;
        break;

    case WM_SETFOCUS:
        if( einfo != NULL && einfo->preview_window != (HWND)NULL ) {
            SendMessage( einfo->preview_window, WM_NCACTIVATE, (WPARAM)TRUE, (LPARAM)NULL );
        }
        break;

#if 0
    case WM_PARENTNOTIFY:
        cmd = GET_WM_PARENTNOTIFY_EVENT( wParam, lParam );
        switch( cmd ) {
        case WM_LBUTTONDOWN:
        case WM_RBUTTONDOWN:
            MAKE_POINT( p, lParam );
            win = GetDlgItem( hDlg, IDM_MENUEDLIST );
            GetClientRect( win, &r );
            MapWindowPoints( win, hDlg, (POINT *)&r, 2 );
            if( PtInRect( &r, p ) ) {
                WHandleSelChange( einfo );
            }
            break;
        }
        ret = TRUE;
        break;
#endif

    case WM_COMMAND:
        wp = LOWORD( wParam );
        cmd = GET_WM_COMMAND_CMD( wParam, lParam );
        switch( wp ) {
        case IDM_MENUEDGRAYED:
            if( IsDlgButtonChecked( hDlg, wp ) ) {
                CheckDlgButton( hDlg, IDM_MENUEDINACTIVE, 0 );
            }
            break;
        case IDM_MENUEDINACTIVE:
            if( IsDlgButtonChecked( hDlg, wp ) ) {
                CheckDlgButton( hDlg, IDM_MENUEDGRAYED, 0 );
            }
            break;
#if 0
        case IDM_MENUEDID:
            if( cmd == CBN_SELCHANGE ) {
                einfo->combo_change = TRUE;
                WHandleSelChange( einfo );
                einfo->combo_change = FALSE;
            }
            break;
#endif
        case IDM_MENUEDINSERT:
            WInsertNew( einfo );
            break;
        case IDM_MENUEDCHANGE:
            WDoHandleSelChange( einfo, TRUE, FALSE );
            break;
        case IDM_MENUEDRESET:
            WDoHandleSelChange( einfo, FALSE, TRUE );
            break;
        case IDM_MENUEDSHIFTLEFT:
            WShiftEntry( einfo, TRUE );
            break;
        case IDM_MENUEDSHIFTRIGHT:
            WShiftEntry( einfo, FALSE );
            break;
        case IDM_MENUEDLIST:
            if( cmd == LBN_SELCHANGE ) {
                WHandleSelChange( einfo );
            }
            break;
        case IDM_MENUEDSETMENU:
            if( einfo->menu != NULL && einfo->menu->first_entry != NULL ) {
                WHandleSelChange( einfo );
            } else {
                WInsertNew( einfo );
            }
            break;
        }
        break;
    }

    return( ret );
}
Beispiel #7
0
static Bool WShiftEntry( WMenuEditInfo *einfo, Bool left )
{
    WMenuEntry  *prev;
    WMenuEntry  *parent;
    WMenuEntry  *entry;
    LRESULT     ret;
    HWND        lbox;
    Bool        entry_removed;
    Bool        ok;

    entry_removed = FALSE;

    ok = (einfo != NULL && einfo->edit_dlg != NULL);

    if( ok ) {
        lbox = GetDlgItem( einfo->edit_dlg, IDM_MENUEDLIST );
        ok = (lbox != NULL);
    }

    if( ok ) {
        ret = SendMessage( lbox, LB_GETCURSEL, 0, 0 );
        ok = (ret != LB_ERR);
    }

    if( ok ) {
        entry = (WMenuEntry *)SendMessage( lbox, LB_GETITEMDATA, (WPARAM)ret, 0 );
        ok = (entry != NULL);
    }

    if( ok ) {
        parent = entry->parent;
        prev = entry->prev;
        ok = WRemoveMenuEntry( einfo->menu, entry );
        if( ok ) {
            entry_removed = TRUE;
        }
    }

    if( ok ) {
        if( left ) {
            ok = WInsertEntryIntoMenu( einfo, parent, parent->parent, entry, FALSE );
        } else {
            if( prev->child != NULL ) {
                parent = prev;
                for( prev = parent->child; prev != NULL && prev->next != NULL;
                     prev = prev->next );
                ok = WInsertEntryIntoMenu( einfo, prev, parent, entry, FALSE );
            } else {
                ok = WInsertEntryIntoMenu( einfo, prev, parent, entry, TRUE );
            }
        }
    }

    if( ok ) {
        ok = WInitEditWindowListBox( einfo );
    }

    if( ok ) {
        einfo->info->modified = TRUE;
        einfo->current_entry = NULL;
        einfo->current_pos = -1;
        ret = SendMessage( lbox, LB_SETCURSEL, (WPARAM)ret, 0 );
        ok = (ret != LB_ERR);
        if( ok ) {
            WHandleSelChange( einfo );
        }
    }

    if( !ok ) {
        if( entry_removed ) {
            WFreeMenuEntries( entry->child );
            WFreeMenuEntry( entry );
            WInitEditWindowListBox( einfo );
        }
    }

    return( ok );
}
Beispiel #8
0
WINEXPORT BOOL CALLBACK WAcccelEditProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
{
    WAccelEditInfo      *einfo;
    HWND                win;
    RECT                r;
    POINT               p;
    BOOL                ret;
    WORD                wp;
    WORD                cmd;

    ret = FALSE;
    einfo = (WAccelEditInfo *)GET_DLGDATA( hDlg );

    switch( message ) {
    case WM_INITDIALOG:
        einfo = (WAccelEditInfo *)lParam;
        einfo->edit_dlg = hDlg;
        SET_DLGDATA( hDlg, einfo );
        WRAddSymbolsToComboBox( einfo->info->symbol_table, hDlg,
                                IDM_ACCEDCMDID, WR_HASHENTRY_ALL );
        ret = TRUE;
        break;

    case WM_SYSCOLORCHANGE:
        WCtl3dColorChange();
        break;

#if 0
#ifdef __NT__
    case WM_CTLCOLORBTN:
    case WM_CTLCOLORDLG:
    case WM_CTLCOLOREDIT:
    case WM_CTLCOLORLISTBOX:
    case WM_CTLCOLORMSGBOX:
    case WM_CTLCOLORSCROLLBAR:
    case WM_CTLCOLORSTATIC:
#else
    case WM_CTLCOLOR:
#endif
        return( WCtl3dCtlColorEx( message, wParam, lParam ) );
#endif

    case WM_LBUTTONDBLCLK:
    case WM_RBUTTONDBLCLK:
    case WM_RBUTTONUP:
        MAKE_POINT( p, lParam );
        win = GetDlgItem( hDlg, IDM_ACCEDRNAME );
        GetClientRect( win, &r );
        MapWindowPoints( win, hDlg, (POINT *)&r, 2 );
        if( PtInRect( &r, p ) ) {
            WHandleRename( einfo );
        }
        ret = TRUE;
        break;

#if 0
    case WM_PARENTNOTIFY:
        cmd = GET_WM_PARENTNOTIFY_EVENT( wParam, lParam );
        switch( cmd ) {
        case WM_LBUTTONDOWN:
        case WM_RBUTTONDOWN:
            MAKE_POINT( p, lParam );
            win = GetDlgItem( hDlg, IDM_ACCEDLIST );
            GetWindowRect( win, &r );
            MapWindowPoints( HWND_DESKTOP, hDlg, (POINT *)&r, 2 );
            if( PtInRect( &r, p ) ) {
                WHandleSelChange( einfo );
            }
            break;
        }
        ret = TRUE;
        break;
#endif

    case WM_COMMAND:
        wp = LOWORD( wParam );
        cmd = GET_WM_COMMAND_CMD( wParam, lParam );
        switch( wp ) {
        case IDM_ACCEDINSERT:
            WInsertAccelEntry( einfo );
            break;
        case IDM_ACCEDCHANGE:
            WHandleChange( einfo );
            break;
        case IDM_ACCEDRESET:
            WDoHandleSelChange( einfo, FALSE, TRUE );
            break;
        case IDM_ACCEDSETACC:
            if( einfo->tbl != NULL && einfo->tbl->num != 0 ) {
                WHandleSelChange( einfo );
            } else {
                WInsertAccelEntry( einfo );
            }
            break;
#if 0
        case IDM_ACCEDCMDID:
            if( cmd == CBN_SELCHANGE ) {
                einfo->combo_change = TRUE;
                WHandleSelChange( einfo );
                einfo->combo_change = FALSE;
            }
            break;
#endif
        case IDM_ACCEDLIST:
            if( cmd == LBN_SELCHANGE ) {
                WHandleSelChange( einfo );
            }
            break;
        case IDM_ACCEDVIRT:
        case IDM_ACCEDASCII:
            if( cmd == BN_CLICKED ) {
                WSetVirtKey( hDlg, wp == IDM_ACCEDVIRT );
            }
            break;
        }
        break;
    }

    return( ret );
}
Beispiel #9
0
Bool WInsertStringEntry( WStringEditInfo *einfo )
{
    HWND                lbox;
    Bool                ok;
    Bool                replace;
    WStringBlock        *block;
    uint_16             id;
    char                *text;
    char                *symbol;
    int                 pos;

    text = NULL;
    symbol = NULL;
    replace = FALSE;

    ok = (einfo != NULL && einfo->tbl != NULL && einfo->edit_dlg != NULL);

    if( ok ) {
        lbox = GetDlgItem ( einfo->edit_dlg, IDM_STREDLIST );
        ok = (lbox != NULL);
    }

    if( ok ) {
        ok = WGetEditWindowText( einfo->edit_dlg, &text );
    }

    if( ok ) {
        ok = WGetEditWindowID( einfo->edit_dlg, &symbol, &id,
                               einfo->info->symbol_table, einfo->combo_change );
    }

    if( ok ) {
        if( id == 0 ) {
            id = DEFAULT_STRING_ID;
        }
        block = WInsertStringData( einfo, id, text, symbol, &replace );
        ok = (block != NULL);
    }

    if( ok ) {
        pos = WFindStringPos( einfo->tbl, id );
        ok = (pos != -1);
    }

    if( ok ) {
        if( replace ) {
            SendMessage( lbox, LB_DELETESTRING, pos, 0 );
        }
        ok = WAddEditWinLBoxEntry( einfo, block, id, pos );
    }


    if( ok ) {
        WSetEditWindowID( einfo->edit_dlg, id, block->symbol[id & 0xf] );
        ok = (SendMessage( lbox, LB_SETCURSEL, pos, 0 ) != LB_ERR);
        if( ok ) {
            einfo->current_block = block;
            einfo->current_string = id;
            einfo->current_pos = pos;
#if 0
            einfo->current_block = NULL;
            einfo->current_string = 0;
            einfo->current_pos = -1;
            WHandleSelChange( einfo );
#endif
        }
    }

    if( ok ) {
        SetFocus( GetDlgItem( einfo->edit_dlg, IDM_STREDTEXT ) );
        SendDlgItemMessage( einfo->edit_dlg, IDM_STREDTEXT, EM_SETSEL,
                            GET_EM_SETSEL_MPS( 0, -1 ) );
    }

    if( symbol != NULL ) {
        WMemFree( symbol );
    }

    if( text != NULL ) {
        WMemFree( text );
    }

    return( ok );
}