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

📄 wdefordr.c

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
Bool WdeCleanOrderedList ( LIST **l )
{
    WdeOrderedEntry *oentry;
    LIST            *tlist;
    LIST            *olist;

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

    tlist = WdeListCopy ( *l );

    for ( olist = tlist; olist; olist = ListNext ( olist ) ) {
        oentry = (WdeOrderedEntry *) ListElement ( olist );
        if ( !oentry->present ) {
            ListRemoveElt ( l, oentry );
            WdeMemFree ( oentry );
        }
    }

    if ( tlist ) {
        ListFree ( tlist );
    }

    return ( TRUE );
}

Bool WdeGetNextChild ( LIST **l, OBJPTR *obj, Bool up )
{
    WdeOrderedEntry *oentry;
    LIST            *o;

    WdeCleanOrderedList ( l );

    if ( l && *l && obj && *obj &&
         ( o = WdeFindOrderedEntry ( *l, *obj ) ) ) {
        if ( up ) {
            o = ListNext ( o );
            if ( !o ) {
                o = *l;
            }
        } else {
            o = ListPrev ( o );
            if ( !o ) {
                WdeListLastElt ( *l, &o );
            }
        }
        oentry = ListElement ( o );
        *obj = oentry->obj;
        return ( TRUE );
    }

    return ( FALSE );
}

void WdeFiniOrderStuff ( void )
{
    if ( WdeTagFont != (HFONT)NULL ) {
        DeleteObject ( WdeTagFont );
    }
}

Bool WdeRegisterTagClass ( HINSTANCE inst )
{
    WNDCLASS  wc;

    WdeAppInst = inst;

    WdeTagFont = WdeGetFont( TAG_FACENAME, TAG_POINTSIZE, FW_BOLD );

    GetClassInfo ( (HINSTANCE)NULL, "BUTTON", &wc );

    wc.style &= ~CS_GLOBALCLASS;
    wc.style |= ( CS_HREDRAW | CS_VREDRAW );

    wc.hInstance     = inst;
    wc.lpszClassName = WdeTagClass;

    WdeTagExtra    = wc.cbWndExtra;
    wc.cbWndExtra += sizeof (WdeSetOrderStruct *);

    WdeOriginalButtonProc = wc.lpfnWndProc;
    wc.lpfnWndProc        = WdeTagProc;

    return ( RegisterClass( &wc ) );
}

void WdeDestroyTag ( HWND tag )
{
    if( ( tag != (HWND)NULL ) && IsWindow( tag ) ) {
        DestroyWindow ( tag );
    }
}

HWND WdeCreateTag( HWND parent, WdeSetOrderStruct *o )
{
    HWND        tag;
    RECT        rect;

    if( !o || !o->res_info || ( parent == (HWND)NULL ) ) {
        return( (HWND)NULL );
    }

    GetWindowRect( parent, &rect );
    MapWindowPoints( (HWND)NULL, o->res_info->forms_win, (POINT *)&rect, 2 );

    tag = CreateWindow( WdeTagClass, NULL,
                        WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,
                        rect.left, rect.top, TAG_WIDTH, TAG_HEIGHT,
                        o->res_info->forms_win,
                        (HMENU) NULL, WdeAppInst, o );

    if( tag != NULL ) {
        if( WdeTagFont != (HFONT)NULL ) {
            SendMessage( tag, WM_SETFONT, (WPARAM)WdeTagFont, FALSE );
        }
        WdeSetTagText( o->old_oe );
    }

    return( tag );
}

void WdeReorderTags ( WdeSetOrderLists *ol, Bool force_redraw )
{
    int              pos;
    LIST            *olist;
    WdeOrderedEntry *oentry;

    pos       = 1;

    for ( olist = ol->newlist; olist; olist = ListNext ( olist ) ) {
        oentry = (WdeOrderedEntry *) ListElement ( olist );
        if ( oentry->present ) {
            if ( force_redraw || ( oentry->pos != pos ) ) {
                oentry->pos = pos;
                WdeSetTagText ( oentry );
            }
            WdeSetTagState ( oentry );
            pos++;
        }
    }

    for ( olist = ol->oldlist; olist; olist = ListNext ( olist ) ) {
        oentry = (WdeOrderedEntry *) ListElement ( olist );
        if ( oentry->present ) {
            if ( force_redraw || ( oentry->pos != pos ) ) {
                oentry->pos = pos;
                WdeSetTagText ( oentry );
            }
            WdeSetTagState ( oentry );
            pos++;
        }
    }
}

void WdeTagPressed ( WdeSetOrderStruct *o )
{
    OBJPTR      parent;
    WORD        state;
    Bool        shift;


    if ( o ) {
        switch ( o->old_oe->mode ) {
            case WdeSetOrder:
                state = (WORD)GetKeyState( VK_SHIFT );
                #ifdef __NT__
                    shift = ( ( state & 0x8000 ) != 0x00 );
                #else
                    shift = ( ( state & 0x80 ) != 0x00 );
                #endif
                if( shift ) {
                    WdeOrderPrevTags( o );
                }
                WdeSetTagOrder( o, TRUE );
                break;
            case WdeSetTabs:
                o->old_oe->tab_set = !o->old_oe->tab_set;
                if ( o->new_oe ) {
                    o->new_oe->tab_set = o->old_oe->tab_set;
                    WdeSetTagText ( o->new_oe );
                } else {
                    WdeSetTagText ( o->old_oe );
                }
                break;
            case WdeSetGroups:
                o->old_oe->grp_set = !o->old_oe->grp_set;
                if ( o->new_oe ) {
                    o->new_oe->grp_set = o->old_oe->grp_set;
                    WdeSetTagText ( o->new_oe );
                } else {
                    WdeSetTagText ( o->old_oe );
                }
                break;
            case WdeSelect:
            default:
                WdeWriteTrail ( "WdeTagPressed: Bad tag mode!" );
                return;
        }
        parent = NULL;
        if ( GetObjectParent ( o->old_oe->obj, &parent ) && parent ) {
            WdeDialogModified ( parent );
        }
    }
}

WdeSetOrderStruct *WdeGetTagInfo ( HWND tag )
{
    if( ( tag != (HWND)NULL ) && IsWindow( tag ) ) {
        return ( (WdeSetOrderStruct *) GetWindowLong ( tag, WdeTagExtra ) );
    }
    return( NULL );
}

LRESULT WINEXPORT WdeTagProc ( HWND hWnd, UINT message, WPARAM wParam,
                               volatile LPARAM lParam )
{
    WdeSetOrderStruct   *o;
    Bool                pass_to_def;
    LRESULT             ret;

    pass_to_def = TRUE;
    ret = FALSE;
    o = (WdeSetOrderStruct *)GetWindowLong( hWnd, WdeTagExtra );

    switch( message ) {

        case WM_CREATE:
            o = (WdeSetOrderStruct *)
                    ((CREATESTRUCT *)lParam)->lpCreateParams;
            o->old_oe->tag = hWnd;
            SetWindowLong( hWnd, WdeTagExtra, (LONG) o );
            break;

        case WM_ERASEBKGND:
            pass_to_def = FALSE;
            ret = TRUE;
            break;

        case WM_LBUTTONDBLCLK:
        case WM_MBUTTONDBLCLK:
        case WM_RBUTTONDBLCLK:
            WdeTagDblClicked( o );
            pass_to_def = FALSE;
            ret = TRUE;
            break;

        case WM_LBUTTONDOWN:
        case WM_MBUTTONDOWN:
        case WM_RBUTTONDOWN:
            if( o ) {
                Notify( o->old_oe->obj, PRIMARY_OBJECT, NULL );
            }
            pass_to_def = FALSE;
            ret = TRUE;
            break;


        case WM_NCLBUTTONDOWN:
        case WM_NCMBUTTONDOWN:
        case WM_NCRBUTTONDOWN:
            if( o ) {
                Notify( o->old_oe->obj, PRIMARY_OBJECT, NULL );
            }
            pass_to_def = FALSE;
            ret = TRUE;
            break;

        case WM_NCLBUTTONUP:
        case WM_NCMBUTTONUP:
        case WM_NCRBUTTONUP:

        case WM_LBUTTONUP:
        case WM_MBUTTONUP:
        case WM_RBUTTONUP:

        case WM_NCLBUTTONDBLCLK:
        case WM_NCMBUTTONDBLCLK:
        case WM_NCRBUTTONDBLCLK:

        case WM_NCMOUSEMOVE:
        case WM_MOUSEMOVE:
            pass_to_def = FALSE;
            ret = TRUE;
            break;

    }

    if( pass_to_def ) {
        ret = CallWindowProc( WdeOriginalButtonProc,
                              hWnd, message, wParam, lParam );
    }

    return( ret );
}

⌨️ 快捷键说明

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