OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [services/] [gfx/] [mw/] [v2_0/] [src/] [nanox/] [nxdraw.c] - Diff between revs 27 and 174

Only display areas with differences | Details | Blame | View Log

Rev 27 Rev 174
/*
/*
 * Copyright (c) 2000 Greg Haerr <greg@censoft.com>
 * Copyright (c) 2000 Greg Haerr <greg@censoft.com>
 *
 *
 * Nano-X Draw Library
 * Nano-X Draw Library
 */
 */
#define MWINCLUDECOLORS
#define MWINCLUDECOLORS
#include <stdio.h>
#include <stdio.h>
#include "nano-X.h"
#include "nano-X.h"
#include "nxdraw.h"
#include "nxdraw.h"
 
 
void
void
nxPaintNCArea(GR_DRAW_ID id, int w, int h, GR_CHAR *title, GR_BOOL active,
nxPaintNCArea(GR_DRAW_ID id, int w, int h, GR_CHAR *title, GR_BOOL active,
        GR_WM_PROPS props)
        GR_WM_PROPS props)
{
{
        int             x = 0;
        int             x = 0;
        int             y = 0;
        int             y = 0;
        GR_GC_ID        gc = GrNewGC();
        GR_GC_ID        gc = GrNewGC();
        GR_FONT_ID      fontid;
        GR_FONT_ID      fontid;
        GR_RECT         r;
        GR_RECT         r;
 
 
 
 
        if (props & GR_WM_PROPS_APPFRAME) {
        if (props & GR_WM_PROPS_APPFRAME) {
                /* draw 2-line 3d border around window*/
                /* draw 2-line 3d border around window*/
                nxDraw3dOutset(id, x, y, w, h);
                nxDraw3dOutset(id, x, y, w, h);
                x += 2; y += 2; w -= 4; h -= 4;
                x += 2; y += 2; w -= 4; h -= 4;
 
 
                /* draw 1-line inset inside border*/
                /* draw 1-line inset inside border*/
                GrSetGCForeground(gc, GrGetSysColor(GR_COLOR_APPWINDOW));
                GrSetGCForeground(gc, GrGetSysColor(GR_COLOR_APPWINDOW));
                GrRect(id, gc, x, y, w, h);
                GrRect(id, gc, x, y, w, h);
                x += 1; y += 1; w -= 2; h -= 2;
                x += 1; y += 1; w -= 2; h -= 2;
        } else if (props & GR_WM_PROPS_BORDER) {
        } else if (props & GR_WM_PROPS_BORDER) {
                /* draw 1-line black border around window*/
                /* draw 1-line black border around window*/
                GrSetGCForeground(gc, GrGetSysColor(GR_COLOR_WINDOWFRAME));
                GrSetGCForeground(gc, GrGetSysColor(GR_COLOR_WINDOWFRAME));
                GrRect(id, gc, x, y, w, h);
                GrRect(id, gc, x, y, w, h);
                x += 1; y += 1; w -= 2; h -= 2;
                x += 1; y += 1; w -= 2; h -= 2;
        }
        }
 
 
        if (!(props & GR_WM_PROPS_CAPTION))
        if (!(props & GR_WM_PROPS_CAPTION))
                goto out;
                goto out;
 
 
        /* fill caption*/
        /* fill caption*/
        GrSetGCForeground(gc,
        GrSetGCForeground(gc,
                GrGetSysColor(active? GR_COLOR_ACTIVECAPTION:
                GrGetSysColor(active? GR_COLOR_ACTIVECAPTION:
                        GR_COLOR_INACTIVECAPTION));
                        GR_COLOR_INACTIVECAPTION));
        GrFillRect(id, gc, x, y, w, CYCAPTION);
        GrFillRect(id, gc, x, y, w, CYCAPTION);
 
 
        /* draw caption text*/
        /* draw caption text*/
        if (title) {
        if (title) {
                GrSetGCForeground(gc,
                GrSetGCForeground(gc,
                        GrGetSysColor(active? GR_COLOR_ACTIVECAPTIONTEXT:
                        GrGetSysColor(active? GR_COLOR_ACTIVECAPTIONTEXT:
                                GR_COLOR_INACTIVECAPTIONTEXT));
                                GR_COLOR_INACTIVECAPTIONTEXT));
                GrSetGCUseBackground(gc, GR_FALSE);
                GrSetGCUseBackground(gc, GR_FALSE);
                fontid = GrCreateFont(GR_FONT_GUI_VAR, 0, NULL);
                fontid = GrCreateFont(GR_FONT_GUI_VAR, 0, NULL);
                GrSetGCFont(gc, fontid);
                GrSetGCFont(gc, fontid);
                GrText(id, gc, x+4, y-1, title, -1, GR_TFASCII|GR_TFTOP);
                GrText(id, gc, x+4, y-1, title, -1, GR_TFASCII|GR_TFTOP);
                GrDestroyFont(fontid);
                GrDestroyFont(fontid);
        }
        }
        y += CYCAPTION;
        y += CYCAPTION;
 
 
        /* draw one line under caption*/
        /* draw one line under caption*/
        if (props & GR_WM_PROPS_APPFRAME) {
        if (props & GR_WM_PROPS_APPFRAME) {
                GrSetGCForeground(gc, GrGetSysColor(GR_COLOR_APPWINDOW));
                GrSetGCForeground(gc, GrGetSysColor(GR_COLOR_APPWINDOW));
                GrLine(id, gc, x, y, x+w-1, y);
                GrLine(id, gc, x, y, x+w-1, y);
        }
        }
 
 
        if (props & GR_WM_PROPS_CLOSEBOX) {
        if (props & GR_WM_PROPS_CLOSEBOX) {
                /* draw close box*/
                /* draw close box*/
                r.x = x + w - CXCLOSEBOX - 2;
                r.x = x + w - CXCLOSEBOX - 2;
                r.y = y - CYCAPTION + 2;
                r.y = y - CYCAPTION + 2;
                r.width = CXCLOSEBOX;
                r.width = CXCLOSEBOX;
                r.height = CYCLOSEBOX;
                r.height = CYCLOSEBOX;
 
 
                nxDraw3dBox(id, r.x, r.y, r.width, r.height,
                nxDraw3dBox(id, r.x, r.y, r.width, r.height,
                        GrGetSysColor(GR_COLOR_BTNHIGHLIGHT),
                        GrGetSysColor(GR_COLOR_BTNHIGHLIGHT),
                        GrGetSysColor(GR_COLOR_WINDOWFRAME));
                        GrGetSysColor(GR_COLOR_WINDOWFRAME));
                nxInflateRect(&r, -1, -1);
                nxInflateRect(&r, -1, -1);
                GrSetGCForeground(gc, GrGetSysColor(GR_COLOR_APPWINDOW));
                GrSetGCForeground(gc, GrGetSysColor(GR_COLOR_APPWINDOW));
                GrFillRect(id, gc, r.x, r.y, r.width, r.height);
                GrFillRect(id, gc, r.x, r.y, r.width, r.height);
 
 
                nxInflateRect(&r, -1, -1);
                nxInflateRect(&r, -1, -1);
                GrSetGCForeground(gc, GrGetSysColor(GR_COLOR_BTNTEXT));
                GrSetGCForeground(gc, GrGetSysColor(GR_COLOR_BTNTEXT));
                GrLine(id, gc, r.x, r.y, r.x+r.width-1, r.y+r.height-1);
                GrLine(id, gc, r.x, r.y, r.x+r.width-1, r.y+r.height-1);
                GrLine(id, gc, r.x, r.y+r.height-1, r.x+r.width-1, r.y);
                GrLine(id, gc, r.x, r.y+r.height-1, r.x+r.width-1, r.y);
        }
        }
 
 
#if 0
#if 0
        /* fill in client area*/
        /* fill in client area*/
        y++;
        y++;
        h -= CYCAPTION+1;
        h -= CYCAPTION+1;
        GrSetGCForeground(gc, GrGetSysColor(GR_COLOR_APPWINDOW));
        GrSetGCForeground(gc, GrGetSysColor(GR_COLOR_APPWINDOW));
        GrFillRect(id, gc, x, y, w, h);
        GrFillRect(id, gc, x, y, w, h);
#endif
#endif
 
 
out:
out:
        GrDestroyGC(gc);
        GrDestroyGC(gc);
}
}
 
 
/*
/*
 * Enlarge/decrease the size of a rectangle
 * Enlarge/decrease the size of a rectangle
 */
 */
void
void
nxInflateRect(GR_RECT *prc, GR_SIZE dx, GR_SIZE dy)
nxInflateRect(GR_RECT *prc, GR_SIZE dx, GR_SIZE dy)
{
{
        prc->x -= dx;
        prc->x -= dx;
        prc->y -= dy;
        prc->y -= dy;
        prc->width += dx * 2;
        prc->width += dx * 2;
        prc->height += dy * 2;
        prc->height += dy * 2;
}
}
 
 
/*
/*
 * nxDraw3dShadow
 * nxDraw3dShadow
 *      NOINDENT_BLACK  T=white, B=black
 *      NOINDENT_BLACK  T=white, B=black
 *      NOINDENT_GRAY   T=white, B=dkgray
 *      NOINDENT_GRAY   T=white, B=dkgray
 *      INDENT_BLACK    T=black, B=white
 *      INDENT_BLACK    T=black, B=white
 *      INDENT_GRAY             T=dkgray, B=white
 *      INDENT_GRAY             T=dkgray, B=white
 *
 *
 *      TTTTTTTTTTTTTT
 *      TTTTTTTTTTTTTT
 *      T             B
 *      T             B
 *      T             B
 *      T             B
 *       BBBBBBBBBBBBBB
 *       BBBBBBBBBBBBBB
 */
 */
void
void
nxDraw3dShadow(GR_DRAW_ID id,int x,int y,int w,int h,GR_COLOR crTop,
nxDraw3dShadow(GR_DRAW_ID id,int x,int y,int w,int h,GR_COLOR crTop,
        GR_COLOR crBottom)
        GR_COLOR crBottom)
{
{
        GR_GC_ID        gc = GrNewGC();
        GR_GC_ID        gc = GrNewGC();
 
 
        GrSetGCForeground(gc, crTop);
        GrSetGCForeground(gc, crTop);
        /*MoveToEx( hDC, x, y+h-2, NULL);*/
        /*MoveToEx( hDC, x, y+h-2, NULL);*/
        /*LineTo( hDC, x, y);*/                         /* left side*/
        /*LineTo( hDC, x, y);*/                         /* left side*/
        GrLine(id, gc, x, y+h-2, x, y);                 /* left*/
        GrLine(id, gc, x, y+h-2, x, y);                 /* left*/
        /*LineTo( hDC, x+w-1, y);*/                     /* top side*/
        /*LineTo( hDC, x+w-1, y);*/                     /* top side*/
        GrLine(id, gc, x, y, x+w-2, y);                 /* top*/
        GrLine(id, gc, x, y, x+w-2, y);                 /* top*/
 
 
        GrSetGCForeground(gc, crBottom);
        GrSetGCForeground(gc, crBottom);
        /*MoveToEx( hDC, x+w-1, y+1, NULL);*/
        /*MoveToEx( hDC, x+w-1, y+1, NULL);*/
        /*LineTo( hDC, x+w-1, y+h-1);*/                 /* right side*/
        /*LineTo( hDC, x+w-1, y+h-1);*/                 /* right side*/
        GrLine(id, gc, x+w-1, y+1, x+w-1, y+h-2);       /* right*/
        GrLine(id, gc, x+w-1, y+1, x+w-1, y+h-2);       /* right*/
        /*LineTo( hDC, x, y+h-1);*/                     /* bottom side*/
        /*LineTo( hDC, x, y+h-1);*/                     /* bottom side*/
        GrLine(id, gc, x+w-1, y+h-1, x, y+h-1);         /* bottom*/
        GrLine(id, gc, x+w-1, y+h-1, x, y+h-1);         /* bottom*/
 
 
        GrDestroyGC(gc);
        GrDestroyGC(gc);
}
}
 
 
/*
/*
 * nxDraw3dBox
 * nxDraw3dBox
 *
 *
 *      TTTTTTTTTTTTTTB
 *      TTTTTTTTTTTTTTB
 *      T             B
 *      T             B
 *      T             B
 *      T             B
 *      BBBBBBBBBBBBBBB
 *      BBBBBBBBBBBBBBB
 */
 */
void
void
nxDraw3dBox(GR_WINDOW_ID id,int x,int y,int w,int h,GR_COLOR crTop,
nxDraw3dBox(GR_WINDOW_ID id,int x,int y,int w,int h,GR_COLOR crTop,
        GR_COLOR crBottom)
        GR_COLOR crBottom)
{
{
        GR_GC_ID        gc = GrNewGC();
        GR_GC_ID        gc = GrNewGC();
 
 
        GrSetGCForeground(gc, crTop);
        GrSetGCForeground(gc, crTop);
        /*MoveToEx( hDC, x, y+h-2, NULL);*/
        /*MoveToEx( hDC, x, y+h-2, NULL);*/
        /*LineTo( hDC, x, y);*/                         /* left side*/
        /*LineTo( hDC, x, y);*/                         /* left side*/
        GrLine(id, gc, x, y+h-2, x, y+1);               /* left*/
        GrLine(id, gc, x, y+h-2, x, y+1);               /* left*/
        /*MoveToEx( hDC, x, y, NULL);*/
        /*MoveToEx( hDC, x, y, NULL);*/
        /*LineTo( hDC, x+w-1, y);*/                     /* top side*/
        /*LineTo( hDC, x+w-1, y);*/                     /* top side*/
        GrLine(id, gc, x, y, x+w-2, y);                 /* top*/
        GrLine(id, gc, x, y, x+w-2, y);                 /* top*/
 
 
        GrSetGCForeground(gc, crBottom);
        GrSetGCForeground(gc, crBottom);
        GrLine(id, gc, x+w-1, y, x+w-1, y+h-2);         /* right*/
        GrLine(id, gc, x+w-1, y, x+w-1, y+h-2);         /* right*/
        /*MoveToEx( hDC, x+w-1, y, NULL);*/
        /*MoveToEx( hDC, x+w-1, y, NULL);*/
        /*LineTo( hDC, x+w-1, y+h-1);*/                 /* right side*/
        /*LineTo( hDC, x+w-1, y+h-1);*/                 /* right side*/
        GrLine(id, gc, x+w-1, y+h-1, x, y+h-1);         /* bottom*/
        GrLine(id, gc, x+w-1, y+h-1, x, y+h-1);         /* bottom*/
        /*LineTo( hDC, x-1, y+h-1);*/                   /* bottom side*/
        /*LineTo( hDC, x-1, y+h-1);*/                   /* bottom side*/
 
 
        GrDestroyGC(gc);
        GrDestroyGC(gc);
}
}
 
 
/*
/*
 * Draw 2 line deep 3d inset
 * Draw 2 line deep 3d inset
 */
 */
void
void
nxDraw3dInset(GR_DRAW_ID id,int x,int y,int w,int h)
nxDraw3dInset(GR_DRAW_ID id,int x,int y,int w,int h)
{
{
        nxDraw3dBox(id, x, y, w, h,
        nxDraw3dBox(id, x, y, w, h,
                GrGetSysColor(GR_COLOR_BTNSHADOW),
                GrGetSysColor(GR_COLOR_BTNSHADOW),
                GrGetSysColor(GR_COLOR_BTNHIGHLIGHT));
                GrGetSysColor(GR_COLOR_BTNHIGHLIGHT));
        ++x; ++y; w -= 2; h -= 2;
        ++x; ++y; w -= 2; h -= 2;
        nxDraw3dBox(id, x, y, w, h,
        nxDraw3dBox(id, x, y, w, h,
                GrGetSysColor(GR_COLOR_WINDOWFRAME),
                GrGetSysColor(GR_COLOR_WINDOWFRAME),
                GrGetSysColor(GR_COLOR_3DLIGHT));
                GrGetSysColor(GR_COLOR_3DLIGHT));
}
}
 
 
/*
/*
 * Draw 2 line deep 3d outset
 * Draw 2 line deep 3d outset
 */
 */
void
void
nxDraw3dOutset(GR_DRAW_ID id,int x,int y,int w,int h)
nxDraw3dOutset(GR_DRAW_ID id,int x,int y,int w,int h)
{
{
        nxDraw3dBox(id, x, y, w, h,
        nxDraw3dBox(id, x, y, w, h,
                GrGetSysColor(GR_COLOR_3DLIGHT),
                GrGetSysColor(GR_COLOR_3DLIGHT),
                GrGetSysColor(GR_COLOR_WINDOWFRAME));
                GrGetSysColor(GR_COLOR_WINDOWFRAME));
        ++x; ++y; w -= 2; h -= 2;
        ++x; ++y; w -= 2; h -= 2;
        nxDraw3dBox(id, x, y, w, h,
        nxDraw3dBox(id, x, y, w, h,
                GrGetSysColor(GR_COLOR_BTNHIGHLIGHT),
                GrGetSysColor(GR_COLOR_BTNHIGHLIGHT),
                GrGetSysColor(GR_COLOR_BTNSHADOW));
                GrGetSysColor(GR_COLOR_BTNSHADOW));
}
}
 
 
/*
/*
 * Draw 1 line pushed down rectangle
 * Draw 1 line pushed down rectangle
 */
 */
void
void
nxDraw3dPushDown(GR_DRAW_ID id, int x, int y, int w, int h)
nxDraw3dPushDown(GR_DRAW_ID id, int x, int y, int w, int h)
{
{
        nxDraw3dBox(id, x, y, w, h, GrGetSysColor(GR_COLOR_BTNSHADOW),
        nxDraw3dBox(id, x, y, w, h, GrGetSysColor(GR_COLOR_BTNSHADOW),
                GrGetSysColor(GR_COLOR_BTNSHADOW));
                GrGetSysColor(GR_COLOR_BTNSHADOW));
}
}
 
 
/*
/*
 * Draw either 3d up or down depending on state
 * Draw either 3d up or down depending on state
 */
 */
void
void
nxDraw3dUpDownState(GR_DRAW_ID id, int x, int y, int w, int h, GR_BOOL fDown)
nxDraw3dUpDownState(GR_DRAW_ID id, int x, int y, int w, int h, GR_BOOL fDown)
{
{
        if (fDown)
        if (fDown)
                nxDraw3dPushDown(id, x, y, w, h);
                nxDraw3dPushDown(id, x, y, w, h);
        else nxDraw3dOutset(id, x, y, w, h);
        else nxDraw3dOutset(id, x, y, w, h);
}
}
 
 
#if 0
#if 0
void
void
nxDraw3dUpFrame(GR_DRAW_ID id, int l, int t, int r, int b)
nxDraw3dUpFrame(GR_DRAW_ID id, int l, int t, int r, int b)
{
{
        RECT    rc;
        RECT    rc;
        HBRUSH  hbr;
        HBRUSH  hbr;
 
 
        SetRect(&rc, l, t, r, b);
        SetRect(&rc, l, t, r, b);
        nxDraw3dBox(hDC, rc.left, rc.top,
        nxDraw3dBox(hDC, rc.left, rc.top,
                rc.right-rc.left, rc.bottom-rc.top,
                rc.right-rc.left, rc.bottom-rc.top,
                GrGetSysColor(GR_COLOR_3DLIGHT),
                GrGetSysColor(GR_COLOR_3DLIGHT),
                GrGetSysColor(GR_COLOR_WINDOWFRAME));
                GrGetSysColor(GR_COLOR_WINDOWFRAME));
        nxInflateRect(&rc, -1, -1);
        nxInflateRect(&rc, -1, -1);
        nxDraw3dBox(hDC, rc.left, rc.top,
        nxDraw3dBox(hDC, rc.left, rc.top,
                rc.right-rc.left, rc.bottom-rc.top,
                rc.right-rc.left, rc.bottom-rc.top,
                GrGetSysColor(GR_COLOR_BTNHIGHLIGHT),
                GrGetSysColor(GR_COLOR_BTNHIGHLIGHT),
                GrGetSysColor(GR_COLOR_BTNSHADOW));
                GrGetSysColor(GR_COLOR_BTNSHADOW));
        nxInflateRect(&rc, -1, -1);
        nxInflateRect(&rc, -1, -1);
 
 
        hbr = CreateSolidBrush(GrGetSysColor(GR_COLOR_APPWINDOW));
        hbr = CreateSolidBrush(GrGetSysColor(GR_COLOR_APPWINDOW));
        FillRect(hDC, &rc, hbr);
        FillRect(hDC, &rc, hbr);
        DeleteObject(hbr);
        DeleteObject(hbr);
}
}
#endif
#endif
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.