⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wdefutil.c

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 C
📖 第 1 页 / 共 4 页
字号:
{
    if ( ( list == NULL) || ( *list == NULL ) ) {
        WdeWriteTrail("WdePutObjFirst: Unexpected NULL list");
        return ( FALSE );
    }

    if ( obj == ListElement(*list) ) {
        return ( TRUE );
    }

    if ( ListFindElt ( *list, obj) ) {
        ListRemoveElt ( list, obj);
        ListAddElt( list, obj );
    } else {
        WdeWriteTrail("WdePutObjFirst: Object not in list");
        return ( FALSE );
    }

    return ( TRUE );
}

Bool WdeFindObjectsAtPt ( POINT *pt, LIST **obj_list, LIST *olist )
{
    SUBOBJ_REQUEST  req;
    OBJPTR          child;
    OBJPTR          sel;
    OBJPTR          first_clear;
    OBJPTR          first_nomove;
    Bool            b;
    Bool            is_clear;
    Bool            can_move;
    LIST           *ol;

    *obj_list = NULL;

    req.p.ty = AT_POINT;
    req.p.pt = *pt;
    if ( !WdeFindSubObjects ( &req, &ol, olist ) ) {
        return ( FALSE );
    }

    sel          = NULL;
    first_clear  = NULL;
    first_nomove = NULL;

    do {
        child = ListElement ( ol );
        is_clear = Forward ( child, IS_OBJECT_CLEAR, &b, NULL ) && b;
        can_move = ValidateAction ( child, PICK, &(req.p.pt) );
        if ( can_move ) {
            sel = child;
            break;
        } else {
            if ( is_clear ) {
                if ( !first_clear ) {
                    first_clear = child;
                }
            } else {
                if ( !first_nomove ) {
                    first_nomove = child;
                }
            }
        }
        ol = ListNext ( ol );
    } while ( ol != NULL );

    if ( sel ) {
        ListAddElt( obj_list, sel );
    } else if ( first_nomove ) {
        ListAddElt( obj_list, first_nomove );
    } else if ( first_clear ) {
        ListAddElt( obj_list, first_clear );
    }

    ListFree ( ol );

    return (*obj_list != NULL);
}

Bool WdeFindSubObjects ( SUBOBJ_REQUEST *req, LIST **obj_list, LIST *olist)
{
    OBJPTR   child;
    RECT     child_rect;

    *obj_list = NULL;

    switch( req->p.ty ) {
        case ALL :
            *obj_list = WdeListCopy ( olist );
            break;

        case BY_POINT :
            return ( WdeFindObjectsAtPt ( &req->p.pt, obj_list, olist ) );

        case AT_POINT :
            for( ; olist; olist = ListNext( olist ) ) {
                child = ListElement( olist );
                Location( child, &child_rect );
                if( PtInRect( &child_rect, req->p.pt ) ) {
                    WdeInsertObject( obj_list, child );
                }
            }
            break;

    }

    return (*obj_list != NULL);
}

char *WdeRectToStr ( RECT *r )
{
    char  temp[41];

    sprintf ( temp, "%d, %d, %d, %d", r->left, r->top, r->right, r->bottom );

    return ( WdeStrDup ( temp ) );
}

void WdeStrToRect ( char *str, RECT *r )
{
    memset ( r, 0, sizeof ( RECT ) );
    sscanf ( str, "%d, %d, %d, %d", &r->left, &r->top,
                                    &r->right, &r->bottom );
}

void WdeDisableChildWindows( HWND hWnd )
{
    HWND win;

    win = GetWindow ( hWnd, GW_CHILD );
    while ( win != NULL ) {
        EnableWindow ( win, FALSE );
        win = GetWindow ( win, GW_HWNDNEXT );
    }

    return;
}

char *WdeGetDefineProcFromOBJID ( Wde_Objects obj_id )
{
    int i;

    for ( i = 0; WdeOBJIDToDefineProc[i].obj_id != LAST__OBJ; i++ ) {
        if( WdeOBJIDToDefineProc[i].obj_id == obj_id ) {
            return ( WdeOBJIDToDefineProc[i].proc_name );
        }
    }

    return ( NULL );
}

void WdeSetDefineControlInfo ( WdeDefineObjectInfo *o_info, HWND hDlg )
{
    char        *cp;
    char        *cp2;

    /* set the control text */
    cp = WdeResNameOrOrdinalToStr( GETCTL_TEXT(o_info->info.c.info), 10 );
    if( cp != NULL ) {
        cp2 = WRConvertStringFrom( cp, "\t\n", "tn" );
        if( cp2 != NULL ) {
            WdeSetEditWithStr( cp2, hDlg, IDB_TEXT );
            WdeMemFree( cp2 );
        }
        WdeMemFree( cp );
    }

    WdeSetWinStyles( hDlg, GETCTL_STYLE(o_info->info.c.info), o_info->mask );

    /* JPK - Help Id stuff is done in here */
    WdeSetDefineObjectSymbolInfo( o_info, hDlg );

    if ( o_info->set_func ) {
        (*(o_info->set_func) )  ( o_info, hDlg );
    }

    return;
}

void WdeGetDefineControlInfo ( WdeDefineObjectInfo *o_info, HWND hDlg )
{
    DialogStyle style;
    char        *cp;
    char        *cp2;
    void        *vp;
    Bool        mod;

    /* set the control text */
    cp = WdeGetStrFromEdit( hDlg, IDB_TEXT, &mod );
    if( mod ) {
        cp2 = WRConvertStringTo( cp, "\t\n", "tn" );
        if( cp2 != NULL ) {
            vp = WdeStrToResNameOrOrdinal( cp2 );
            if( GETCTL_TEXT(o_info->info.c.info) ) {
                WdeMemFree( GETCTL_TEXT(o_info->info.c.info) );
            }
            SETCTL_TEXT(o_info->info.c.info, (ResNameOrOrdinal *) vp );
            WdeMemFree( cp2 );
        }
        WdeMemFree( cp );
    }

    WdeGetDefineObjectSymbolInfo ( o_info, hDlg );
    WdeGetDefineObjectHelpSymbolInfo ( o_info, hDlg );

    style = GETCTL_STYLE(o_info->info.c.info);
    WdeGetWinStyles( hDlg, &style, o_info->mask );
    SETCTL_STYLE(o_info->info.c.info, style);

    if( o_info->get_func ) {
        (*(o_info->get_func) ) ( o_info, hDlg );
    }

}


void WdeSetDefineObjectSymbolInfo( WdeDefineObjectInfo *o_info, HWND hDlg )
{
    int_32 helpid;

    if( !o_info ) {
        return;
    }

    if( o_info->res_info->hash_table ) {
        WdeAddSymbolsToComboBox( o_info->res_info->hash_table,
                                 hDlg, IDB_SYMBOL );
        // JPK - add for help id
        WdeAddSymbolsToComboBox( o_info->res_info->hash_table,
                                 hDlg, IDB_HELPSYMBOL );
    }

    if( o_info->obj_id == DIALOG_OBJ ) {        /* dialog object */

        if( o_info->info.d.name && o_info->info.d.name->IsName ) {
            char *str1, *str2;
            int len;
            str1 = WResIDToStr( o_info->info.d.name );
            if( str1 ) {
                len = strlen( str1 ) + 3;
                str2 = WdeMemAlloc( len );
                if( str2 ) {
                    str2[0] = '"';
                    strcpy( &str2[1], str1 );
                    str2[len-2] = '"';
                    str2[len-1] = '\0';
                    WdeSetEditWithStr( str2, hDlg, IDB_SYMBOL );
                    WdeMemFree( str2 );
                }
                WdeMemFree( str1 );
            }
            o_info->info.d.id     = 0;
            o_info->info.d.use_id = FALSE;
        } else {
            if( o_info->symbol ) {
                WdeSetComboWithStr( o_info->symbol, hDlg, IDB_SYMBOL );
            } else {
                WdeSetEditWithSINT16( (int_16)o_info->info.d.name->ID.Num,
                                      10, hDlg, IDB_SYMBOL );
            }
            o_info->info.d.id     = (uint_16)o_info->info.d.name->ID.Num;
            o_info->info.d.use_id = TRUE;
            WdeSetEditWithSINT16( (int_16) o_info->info.d.name->ID.Num,
                                  10, hDlg, IDB_ID );
        }

        /* JPK - added for help id */
        helpid = GETHDR_HELPID(o_info->info.d.header);
        if( o_info->info.d.header->helpsymbol ) {
            WdeSetComboWithStr( o_info->info.d.header->helpsymbol, hDlg, IDB_HELPSYMBOL );
        } else {
            if (helpid > 0) {
                WdeSetEditWithSINT32( helpid, 10, hDlg, IDB_HELPSYMBOL );
            }
        }
        if (helpid > 0) {
            WdeSetEditWithSINT32( helpid, 10, hDlg, IDB_HELPID );
        }

    } else {    /* this is a control object */

        if( o_info->symbol ) {
            WdeSetComboWithStr( o_info->symbol, hDlg, IDB_SYMBOL );
        } else {
            WdeSetEditWithSINT16( (int_16)GETCTL_ID(o_info->info.c.info),
                                  10, hDlg, IDB_SYMBOL );
        }

        WdeSetEditWithSINT16( (int_16) GETCTL_ID(o_info->info.c.info),
                              10, hDlg, IDB_ID );

        /* JPK - added for help id */
        helpid = GETCTL_HELPID(o_info->info.c.info);
        if( o_info->info.c.info->helpsymbol ) {
            WdeSetComboWithStr( o_info->info.c.info->helpsymbol, hDlg, IDB_HELPSYMBOL );
        } else {
            if (helpid > 0) {
                WdeSetEditWithSINT32( helpid, 10, hDlg, IDB_HELPSYMBOL );
            }
        }
        if (helpid > 0) {
            WdeSetEditWithSINT32( helpid, 10, hDlg, IDB_HELPID );
        }
    }
}

void WdeGetDefineObjectSymbolInfo( WdeDefineObjectInfo *o_info, HWND hDlg )
{
    char                *str;
    char                *cp;
    Bool                dup;
    Bool                quoted_str;
    Bool                str_is_ordinal;
    uint_16             ord;
    WdeHashEntry        *entry;

    if( !o_info ) {
        return;
    }

    if( o_info->symbol ) {
        WdeMemFree( o_info->symbol );
    }
    o_info->symbol = NULL;

    str = WdeGetStrFromCombo( hDlg, IDB_SYMBOL );
    if( str == NULL ) {
        return;
    }

    WRStripSymbol( str );

    quoted_str = FALSE;
    if( str[0] == '"' ) {
        char    *s;
        str[0] = ' ';
        cp = NULL;
        for( s=str; *s; s=_mbsinc(s) ) {
            if( _mbclen( s ) == 1 && *s == '"' ) {
                cp = s;
            }
        }
        if( cp ) {
            *cp = '\0';
        }
        WRStripSymbol( str );
        quoted_str = TRUE;
    }

    if( str[0] == '\0' ) {
        WdeMemFree( str );
        return;
    }

    ord = ( uint_16 )strtoul( str, &cp, 0 );
    str_is_ordinal = ( *cp == '\0' );

    if( o_info->obj_id == DIALOG_OBJ ) {

        if( o_info->info.d.name ) {
            WdeMemFree( o_info->info.d.name );
        }
        o_info->info.d.name = NULL;

        if( quoted_str ) {
            o_info->info.d.name = WResIDFromStr( str );
        } else if( str_is_ordinal ) {
            o_info->info.d.name = WResIDFromNum( ord );
        } else {
            dup = FALSE;
            o_info->symbol = WdeStrDup( str );
            strupr( o_info->symbol );
            entry = WdeDefAddHashEntry( o_info->res_info->hash_table,
                                        str, &dup );
            o_info->info.d.name = WResIDFromNum( entry->value );
        }

    } else {

        if( str_is_ordinal ) {
            SETCTL_ID( o_info->info.c.info, ord );
        } else {
            dup = FALSE;
            o_info->symbol = WdeStrDup( str );
            strupr( o_info->symbol );
            entry = WdeDefAddHashEntry( o_info->res_info->hash_table,
                                        str, &dup );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -