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

📄 wdefcntl.c

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
    if ( oid == COMBOBOX_OBJ ) {
        style = GETCTL_STYLE( obj->control_info ) &
            ( 0xffffffff ^ ( CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE ) );
    }

    ID = GETCTL_ID(obj->control_info);
    if( !stricmp ( obj->window_class, "wde_borbtn" )  ) {
        if( !WdeIsBorBtnIDSupported( GETCTL_ID(obj->control_info) ) ) {
            ID = WDE_PREVIEW_ID;
        }
        set_font = FALSE;
        set_crt_params = FALSE;
    }

    if( !set_font ) {
        cname = name;
    }

    if ( set_crt_params ) {
        crt_params = (void *) obj->object_handle;
    } else {
        crt_params = NULL;
    }

    #if 1
        style |= WS_VISIBLE;
    #else
        if( oid == GBUTTON_OBJ ) {
            style |= WS_VISIBLE;
        } else {
            style |= ( WS_VISIBLE | WS_CLIPSIBLINGS );
        }
    #endif

    obj->window_handle =
        CreateWindowEx( exstyle,
                        obj->window_class,
                        cname,
                        style,
                        pnt.x,
                        pnt.y,
                        (obj_rect.right  - obj_rect.left),
                        (obj_rect.bottom - obj_rect.top),
                        obj->parent_handle,
                        (HMENU) ID,
                        WdeAppInst,
                        crt_params );

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

    // 3D subclass the control
    if( WdeGetOption( WdeOptUse3DEffects ) ) {
        WdeCtl3dSubclassCtl( obj->window_handle );
    }

    // subclass the control
    obj->old_proc = (WNDPROC)GetWindowLong( obj->window_handle, GWL_WNDPROC );
    if( obj->old_proc == (WNDPROC)NULL ) {
        DestroyWindow( obj->window_handle );
        obj->window_handle = NULL;
        return( FALSE );
    }
    SetWindowLong( obj->window_handle, GWL_WNDPROC, (LONG)new_proc );

    if( set_font ) {
        SendMessage ( obj->window_handle, WM_SETFONT,
                      (WPARAM) obj->font, (LPARAM) TRUE);

        SendMessage ( obj->window_handle, WM_SETTEXT, 0, (LPARAM) name);
    }

    WdeBringControlToTop ( obj );

    ShowWindow ( obj->window_handle, SW_SHOW );

    return ( TRUE );
}

BOOL WdeControlDestroyWindow ( WdeControlObject *obj, Bool *quick,
                               Bool *destroy_children )
{
    /* touch unused vars to get rid of warning */
    _wde_touch(destroy_children);

    if ( !quick || ( !*quick && (obj->window_handle != NULL) ) ) {
        DestroyWindow ( obj->window_handle );
    }

    obj->window_handle = NULL;
    obj->tag           = NULL;

    return ( TRUE );
}

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

    WdeShowObjectWindow ( obj->window_handle, *flag );

    return ( TRUE );
}

BOOL WdeControlGetResizeInfo ( WdeControlObject *obj, RESIZE_ID *info, void *p2 )
{
    /* touch unused vars to get rid of warning */
    _wde_touch(obj);
    _wde_touch(p2);

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

    return ( TRUE );
}

static BOOL WdeControlValidateMove( WdeControlObject *obj, POINT *pnt,
                                    ACTION act )
{
    RECT        obj_rect;
    RECT        win_rect;
    OBJ_ID      id;
    BOOL        clear;

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

    id = BASE_OBJ;
    Forward( obj->object_handle, IDENTIFY, &id, NULL );

    if( id == COMBOBOX_OBJ ) {
        Location( (OBJPTR)obj, &obj_rect );
        GetWindowRect( obj->window_handle, &win_rect );
        obj_rect.bottom = obj_rect.top + win_rect.bottom - win_rect.top;
        return( PtInRect( &obj_rect, *pnt ) );
    }

    clear = obj->clear_interior;

    if( !clear && ( id == FRAME_OBJ ) ) {
        DialogStyle     mask;

        mask = GETCTL_STYLE( obj->control_info ) & 0x0000000F;

        if( ( mask != SS_BLACKRECT ) && ( mask != SS_GRAYRECT ) &&
            ( mask != SS_WHITERECT ) ) {
            clear = TRUE;
        }
    }


    if( clear ) {
        Location( (OBJPTR)obj, &obj_rect );
        obj_rect.left   += WDE_BORDER_SIZE;
        obj_rect.right  -= WDE_BORDER_SIZE;
        obj_rect.top    += WDE_BORDER_SIZE;
        obj_rect.bottom -= WDE_BORDER_SIZE;
        return( !PtInRect( &obj_rect, *pnt ) );
    }

    return( TRUE );
}

BOOL WdeControlValidateAction( WdeControlObject *obj, ACTION *act, void *p2 )
{
    int     i;

    if( ( *act == MOVE ) || ( *act == PICK ) ) {
        return( WdeControlValidateMove( obj, (POINT *)p2, *act ) );
    }

    for( i = 0; i < MAX_ACTIONS; i++ ) {
        if( WdeControlActions[i].id == *act ) {
            return( TRUE );
        }
    }

    return( ValidateAction( (OBJPTR) obj->o_item, *act, p2 ) );
}

BOOL WdeControlGetWindowHandle ( WdeControlObject *obj, HWND *hwin, void *p2 )
{
    /* touch unused vars to get rid of warning */
    _wde_touch(p2);

    *hwin = obj->window_handle;

    return ( TRUE );
}

BOOL WdeControlPasteObject ( WdeControlObject *obj, OBJPTR parent,
                             POINT *pnt )
{
    Bool ok;

    obj->base_obj = GetMainObject ();
    obj->res_info = WdeGetCurrentRes ();

    ok = ( obj->base_obj && obj->res_info );

    if ( ok ) {
        if ( pnt ) {
            ok = PasteObject ( obj->o_item, parent, *pnt );
            if ( !ok ) {
                WdeWriteTrail("WdeControlPasteObject: OITEM PASTE failed!");
            }
        } else {
            obj->parent = NULL;
            ok = Notify ( obj->object_handle, NEW_PARENT, parent );
        }
    }

    if ( ok && pnt ) {
        ok = WdeOffsetDialogUnits ( obj, NULL );
        if ( !ok ) {
            WdeWriteTrail ( "WdeControlPasteObject: "
                            "WdeOffsetDialogUnits failed!" );
        }
    }

    if ( ok ) {
        ok = WdeChangeControlSize ( obj, FALSE, TRUE );
        if ( !ok ) {
            WdeWriteTrail ( "WdeControlPasteObject: "
                            "WdeChangeControlSize failed!" );
        }
    }

    if ( ok ) {
        ok = Forward ( obj->object_handle, CREATE_WINDOW, NULL, NULL );
        if ( !ok ) {
            WdeWriteTrail("WdeControlPasteObject: create window falied!");
        }
    }

    if ( ok ) {
        WdeControlModified ( obj );
        if ( obj->symbol ) {
            WdeAddSymbolToObjectHashTable ( obj->res_info, obj->symbol,
                                            GETCTL_ID(obj->control_info) );
        }
        WdeControlOnTop ( obj, NULL, NULL);
    } else {
        obj->base_obj = NULL;
        obj->res_info = NULL;
    }

    return ( ok );
}

BOOL WdeControlCopyObject ( WdeControlObject *obj, WdeControlObject **new,
                            WdeControlObject *handle )
{
    if (new == NULL) {
        WdeWriteTrail("WdeControlCopyObject: Invalid new object!");
        return ( FALSE );
    }

    *new = (WdeControlObject *) WdeMemAlloc ( sizeof(WdeControlObject) );

    if ( *new == NULL ) {
        WdeWriteTrail("WdeControlCopyObject: Object malloc failed");
        return ( FALSE );
    }
    memset ( *new, 0, sizeof(WdeControlObject) );

    (*new)->dispatcher     = obj->dispatcher;
    (*new)->window_class   = obj->window_class;
    (*new)->font           = obj->font;
    (*new)->sizeable       = obj->sizeable;
    (*new)->clear_interior = obj->clear_interior;
    (*new)->control_info   = WdeCopyDialogBoxControl ( obj->control_info );
    (*new)->mode           = WdeSelect;

    if ( !(*new)->control_info ) {
        WdeWriteTrail("WdeControlCopyObject: NULL info!");
        WdeFreeControlObject ( *new );
        return ( FALSE );
    }

    SETCTL_ID( (*new)->control_info, WdeGetNextControlID() );

    if ( obj->symbol ) {
        (*new)->symbol = WdeStrDup ( obj->symbol );
        if ( (*new)->symbol == NULL ) {
            WdeWriteTrail("WdeControlCopyObject: Symbol alloc failed");
            WdeFreeControlObject (*new);
            return ( FALSE );
        }
    }

    /* JPK - added for help id support */
    if ( obj->helpsymbol ) {
        (*new)->helpsymbol = WdeStrDup ( obj->helpsymbol );
        if ( (*new)->helpsymbol == NULL ) {
            WdeWriteTrail("WdeControlCopyObject: Help symbol alloc failed");
            WdeFreeControlObject (*new);
            return ( FALSE );
        }
    }

    if ( handle ==  NULL ) {
        (*new)->object_handle = *new;
    } else {
        (*new)->object_handle = handle;
    }

    if (!CopyObject(obj->o_item, &((*new)->o_item), (*new)->object_handle)) {
        WdeWriteTrail("WdeControlCopyObject: OITEM not created!");
        WdeFreeControlObject (*new);
        return ( FALSE );
    }

    return ( TRUE );
}

BOOL WdeControlCutObject ( WdeControlObject *obj, WdeControlObject **new,
                           void *p2 )
{
    NOTE_ID     note_id;
    Bool        check_scroll;

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

    *new = NULL;

    check_scroll = ( obj->parent == obj->base_obj );

    if (!RemoveObject(obj->parent, obj->object_handle) ) {
        WdeWriteTrail("WdeControlCutObject: Remove from parent failed!");
        return ( FALSE );
    }

    note_id = NEW_PARENT;
    if ( !WdeControlNotify ( obj, &note_id, NULL ) ) {
        WdeWriteTrail("WdeControlCutObject: New parent notify failed!");
        if (!AddObject(obj->parent, obj->object_handle) ) {
            WdeWriteTrail("WdeControlCutObject: Add to parent failed!");
        }
        return ( FALSE );
    }

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

    obj->window_handle = NULL;

    *new = obj->object_handle;

    WdeControlModified ( obj );

    if( check_scroll ) {
        WdeCheckBaseScrollbars( FALSE );
    }

    return ( TRUE );
}

BOOL WdeControlFirstChild ( WdeControlObject *obj, void *p1, void *p2 )
{
    /* touch unused vars to get rid of warning */
    _wde_touch(p1);
    _wde_touch(p2);

    if ( obj->parent == NULL) {
        return ( TRUE );
    }

    if (!Forward ( obj->parent, PUT_ME_FIRST, obj->object_handle, NULL)) {
        WdeWriteTrail("WdeControlFirstChild: PUT_ME_FIRST failed!");
        return ( FALSE );
    }

    WdeBringControlToTop ( obj );

    return ( TRUE );
}

void WdeWriteControlToInfo ( WdeControlObject *obj )
{
    WdeInfoStruct is;

    is.obj_id   = CONTROL_OBJ;
    is.res_info = obj->res_info;
    is.obj      = obj->object_handle;
    is.size     = GETCTL_SIZE( obj->control_info );
    is.c.text   = GETCTL_TEXT( obj->control_info );
    is.c.id     = GETCTL_ID( obj->control_info );
    is.symbol   = WdeStrDup( obj->symbol );
//    is.helpsymbol   = WdeStrDup( obj->helpsymbol );

    WdeWriteInfo ( &is );

    if( is.symbol != NULL ) {
        WdeMemFree( is.symbol );
    }
//    if( is.helpsymbol != NULL ) {
//      WdeMemFree( is.helpsymbol );
//    }

⌨️ 快捷键说明

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