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

📄 wdefdiag.c

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
    }

    if (!Forward ( obj->parent, GET_FONT, &WdeLastFont, NULL)) {
        WdeWriteTrail("WdeDialogCreateWindow: Couldn't get parent font!");
        GlobalFree(hglobal_mem);
        return ( FALSE );
    }

    obj->window_handle =
        CreateDialogIndirect ( WdeAppInst, WDEDLGTEMPLATE locked_global_mem,
                               obj->parent_handle, WdeDialogProcInst);

    GlobalUnlock(hglobal_mem);

    GlobalFree(hglobal_mem);

    if ( obj->window_handle == NULL ) {
        WdeWriteTrail("WdeDialogCreateWindow: Could not create window!");
        return ( FALSE );
    }

    // get the expected location of the dialog
    Location( (OBJPTR)obj, &rect );
    SetWindowPos( obj->window_handle, (HWND) NULL,
                  rect.left, rect.top, 0, 0, SWP_NOZORDER | SWP_NOSIZE );

    if ( !WdeCalcDialogNCSize ( obj, &obj->nc_size ) ) {
        WdeWriteTrail("WdeDialogCreateWindow: WdeCalcDialogNCSize failed!");
    }

    SetRect ( &rect, 4, 8, 0, 0 );
    MapDialogRect ( obj->window_handle, &rect );
    obj->resizer.xmap = rect.left;
    obj->resizer.ymap = rect.top;

    if ( !WdeDialogSetFont ( obj, &WdeLastFont, &(obj->resizer) ) ) {
        WdeWriteTrail("WdeDialogCreateWindow: SET_FONT failed!");
        return ( FALSE );
    }

    /* let's recreate the children in reverse order */
    if ( obj->children ) {
        WdeListLastElt ( obj->children, &olist );
    } else {
        olist = NULL;
    }

    for ( ; olist; olist = ListPrev ( olist ) ) {
        OBJ_ID  id;
        child = ListElement ( olist );
        if( !Forward ( child, CREATE_WINDOW, NULL, NULL ) ) {
            WdeWriteTrail("WdeDialogCreateWindow: "
                          "Failed to create child window!");
            return ( FALSE );
        }
        if( Forward( child, IDENTIFY, &id, NULL ) && ( id == SBAR_OBJ ) ) {
            WdeSBNoodleSize( child, TRUE );
        }
    }

    WdeDialogOnTop ( obj, NULL, NULL );

    SendMessage ( obj->window_handle, WM_NCACTIVATE, TRUE, 0 );

    if ( !show || ( show && *show ) ) {
        ShowWindow ( obj->window_handle, SW_SHOW );
    }

    return ( TRUE );
}

Bool WdeDialogOnTop ( WdeDialogObject *obj, void *p1, void *p2 )
{
    /* touch unused vars to get rid of warning */
    _wde_touch(p1);
    _wde_touch(p2);

    WdeBringWindowToTop ( obj->window_handle );
#ifdef __NT__
    SendMessage( obj->window_handle, WM_NCACTIVATE, (WPARAM)TRUE, 0 );
#endif

    return ( TRUE );
}

Bool WdeDialogAddSubObject( WdeDialogObject *dialog, OBJPTR obj, void *p2)
{
    OBJ_ID      id;
    RECT        dialog_rect;
    RECT        obj_rect;
    POINT       pnt;
    int         fudge;

    /* touch unused vars to get rid of warning */
    _wde_touch(p2);

    /* make sure the object is not another dialog object */
    Forward ((OBJPTR)obj, IDENTIFY, &id, NULL);
    if ( id == DIALOG_OBJ ) {
        return ( Forward(dialog->parent, ADD_SUBOBJECT, obj, p2) );
    }

    /* make sure the objects top left corner is south east of the
     * dialogs top left corner
     */
    Location( obj,    &obj_rect );
    Location( (OBJPTR)dialog, &dialog_rect );

    dialog_rect.left   += dialog->nc_size.left;
    dialog_rect.right  -= dialog->nc_size.right;
    dialog_rect.top    += dialog->nc_size.top;
    dialog_rect.bottom -= dialog->nc_size.bottom;

    pnt.x = obj_rect.left;
    pnt.y = obj_rect.top;

    fudge = 0;
    if( id == SBAR_OBJ ) {
        fudge = 10;
    }

    if( ( pnt.x < ( dialog_rect.left - fudge ) ) ||
        ( pnt.y < dialog_rect.top ) ) {
        WdeWriteTrail("WdeDialogAddSubObject: "
                      "Cntrl not contained by dialog top left!");
        return ( FALSE );
    }

    if ( dialog->num_children < WDE_DIALOG_MAX_CONTROLS ) {
        /* object will be inserted at the end of the list */
        WdeInsertObject ( &(dialog->children), obj );
        WdeAddOrderedEntry ( &(dialog->ochildren), obj );
        dialog->num_children++;

        if ( !Notify(obj,NEW_PARENT,dialog->object_handle) ) {
            WdeWriteTrail("WdeDialogAddSubObject: NEW_PARENT notify failed!");
            return ( FALSE );
        }
    } else {
        WdeWriteTrail("WdeDialogAddSubObject: Dialog full!");
        WdeDisplayErrorMsg( WDE_DIALOGFULL );
        return ( FALSE );
    }

    return ( TRUE );
}

Bool WdeCalcDialogNCSize ( WdeDialogObject *obj, RECT *size )
{
    RECT          win_rect;
    RECT          client_rect;

    if ( obj && ( obj->window_handle != NULL ) ) {
        GetWindowRect ( obj->window_handle, &win_rect );
        GetClientRect ( obj->window_handle, &client_rect );
        WdeMapWindowRect ( obj->window_handle, (HWND) NULL, &client_rect );

        size->left    = client_rect.left - win_rect.left;
        size->top     = client_rect.top  - win_rect.top;
        size->right   = win_rect.right   - client_rect.right;
        size->bottom  = win_rect.bottom  - client_rect.bottom;
    } else {
        return ( FALSE );
    }

    return ( TRUE );
}

Bool WdeDialogGetNCSize ( WdeDialogObject *obj, RECT *size, void *p2)
{
    /* touch unused vars to get rid of warning */
    _wde_touch(p2);

    *size = obj->nc_size;

    return ( TRUE );
}

Bool WdeDialogFindSubObjects ( WdeDialogObject *obj, SUBOBJ_REQUEST *req,
                               LIST **obj_list )
{
    return ( WdeFindSubObjects ( req, obj_list, obj->children ) );
}

Bool WdeDialogFindObjectsPt ( WdeDialogObject *obj, POINT *pt,
                              LIST **obj_list )
{
    LIST   *subobjs;

    if ( WdeFindObjectsAtPt ( pt, &subobjs, obj->children ) ) {
        ListAddElt ( obj_list, ListElement ( subobjs ) );
        ListFree ( subobjs );
    } else {
        ListAddElt ( obj_list, obj );
    }

    return ( TRUE );
}

Bool WdeDialogGetNextChild ( WdeDialogObject *obj, OBJPTR *o, Bool *up )
{
    return ( WdeGetNextChild ( &obj->ochildren, o, *up ) );
}

Bool WdeDialogRemoveSubObject ( WdeDialogObject *dialog, OBJPTR obj, void *p2 )
{
    /* touch unused vars to get rid of warning */
    _wde_touch(p2);

    if ( dialog->num_children && ListFindElt ( dialog->children, obj ) ) {
        ListRemoveElt ( &(dialog->children), obj);
        WdeRemoveOrderedEntry ( dialog->ochildren, obj);
        dialog->num_children--;
        if ( !dialog->num_children ) {
            dialog->children = NULL;
        }
    } else {
        return ( FALSE );
    }

    WdeDialogModified ( dialog );

    return ( TRUE );
}

Bool WdeDialogGetSubObjectList ( WdeDialogObject *obj, LIST **l, void *p2 )
{
    /* touch unused vars to get rid of warning */
    _wde_touch(p2);

    *l = obj->children;

    return( TRUE );
}

Bool WdeDialogDraw( WdeDialogObject *obj, RECT *area, HDC *dc )
{
    RECT        rect;
    POINT       origin;
    RECT        trect;
    OBJPTR      child;
    RECT        child_rect;

    Location( obj->object_handle, &rect );

    GetOffset( &origin );

    if( obj->children != NULL ) {
        child = ListElement( obj->children );
        Location( child, &child_rect ) ;
        if( IntersectRect( &trect, area, &child_rect ) ) {
            if( !Forward( child, ON_TOP, NULL, NULL ) ) {
                WdeWriteTrail( "WdeDialogDraw: child ON_TOP failed!" );
                return( FALSE );
            }
        }
    }

    if( dc && IntersectRect( &trect, area, &rect ) ) {
        OffsetRect( &trect, -origin.x, -origin.y );
        RedrawWindow( obj->res_info->edit_win, &trect, (HRGN) NULL,
                      RDW_INTERNALPAINT | //RDW_INVALIDATE |
                      RDW_UPDATENOW );
        //SendMessage( obj->window_handle, WM_NCACTIVATE, (WPARAM)TRUE, NULL );
    }

    OffsetRect ( &rect, -origin.x, -origin.y );

    SetWindowPos( obj->window_handle, (HWND) NULL, rect.left, rect.top, 0, 0,
                  SWP_NOZORDER | SWP_NOSIZE | ( (dc) ? 0 : SWP_NOREDRAW ) );

    SendMessage( obj->window_handle, WM_NCACTIVATE, (WPARAM)TRUE, 0 );

    return( TRUE );
}

Bool WdeDialogSetFont( WdeDialogObject *obj, HFONT *font,
                        WdeResizeRatio *resizer )
{
    LIST           *olist;
    OBJPTR          child;

    obj->font = *font;

    if( !WdeKludgeDialogSize( obj, TRUE, FALSE ) ) {
        WdeWriteTrail("WdeDialogSetFont: Couldn't kludge size!");
        return ( FALSE );
    }

    /* we must set the font of all children in reverse order */
    if ( obj->children ) {
        WdeListLastElt ( obj->children, &olist );
    } else {
        olist = NULL;
    }

    for ( ; olist; olist = ListPrev ( olist ) ) {
        child = ListElement ( olist );
        if (!Forward ( child, SET_FONT, font, resizer )) {
            WdeWriteTrail("WdeDialogSetFont: Couldn't set child font!");
            return ( FALSE );
        }
    }

    return ( TRUE );
}

Bool WdeDialogDestroyWindow( WdeDialogObject *obj, Bool *quick,
                             Bool *destroy_children )
{
    LIST        *olist;
    OBJPTR      child;
    RECT        rect;

    Location( obj->object_handle, &rect );

    if( destroy_children && *destroy_children ) {
        for( olist = obj->children; olist; olist = ListNext( olist ) ) {
            child = ListElement( olist );
            if( !Forward( child, DESTROY_WINDOW, quick, NULL ) ) {
                WdeWriteTrail( "WdeDialogDestroyWindow: "
                               "DESTROY_WINDOW failed!" );
            }
        }
    }

    if( obj->window_handle != NULL ) {
        DestroyWindow(obj->window_handle);
    }

    obj->window_handle = NULL;

    MarkInvalid( &rect );

    return( TRUE );
}

Bool WdeDialogShowWindow( WdeDialogObject *obj, Bool *flag, void *p2 )
{
    /* touch unused vars to get rid of warning */
    _wde_touch(p2);

    if ( !flag ) {
        return ( FALSE );
    }

    WdeShowObjectWindow ( obj->window_handle, *flag );

    return ( TRUE );
}

Bool WdeDialogGetResizeInfo ( WdeDialogObject *obj, RESIZE_ID *info, void *p2 )
{
    /* touch unused vars to get rid of warning */
    _wde_touch(obj);
    _wde_touch(p2);

    if ( obj->mode == WdeSelect ) {
        *info = R_ALL;
    } else {
        *info = R_NONE;
    }

    return ( TRUE );
}

static Bool WdeDialogValidateMove( WdeDialogObject *obj, POINT *pnt,
                                   ACTION act )
{
    RECT obj_rect;
    RECT nc_size;

    if( ( act == MOVE ) && ( obj->mode != WdeSelect ) ) {
        return( FALSE );
    }

    Location( (OBJPTR)obj, &obj_rect );

    nc_size.left    = max( obj->nc_size.left,   DIALOG_MIN_SIZE_BORDER );
    nc_size.top     = max( obj->nc_size.top ,   DIALOG_MIN_SIZE_BORDER );
    nc_size.right   = max( obj->nc_size.right,  DIALOG_MIN_SIZE_BORDER );
    nc_size.bottom  = max( obj->nc_size.bottom, DIALOG_MIN_SIZE_BORDER );

    obj_rect.left   += nc_size.left;
    obj_rect.right  -= nc_size.right;
    obj_rect.top    += nc_size.top;
    obj_rect.bottom -= nc_size.bottom;

    if( PtInRect( &obj_rect, *pnt ) ) {
        return( FALSE );
    }

    return( TRUE );
}

Bool WdeDialogValidateAction( WdeDialogObject *obj, ACTION *act, void *p2 )
{
    int     i;

    if( ( *act == MOVE ) || ( *act == PICK ) ) {
        

⌨️ 快捷键说明

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