Tk Source Code

Check-in [ac543027]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Commit changes received from René Zaumseil
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tip-510
Files: files | file ages | folders
SHA3-256: ac54302764eebe66fdff5fee32de92039b416668a081d997c231032922c07fa3
User & Date: fvogel 2018-07-04 20:06:54
Context
2018-07-05
11:24
Remove debug code check-in: c77f765d user: fvogel tags: tip-510
2018-07-04
20:06
Commit changes received from René Zaumseil check-in: ac543027 user: fvogel tags: tip-510
2018-06-28
18:24
Commit changes received from René Zaumseil check-in: f80ff0cf user: fvogel tags: tip-510
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/rbc/rbcGrAxis.c.

2811
2812
2813
2814
2815
2816
2817





2818
2819
2820
2821
2822
2823
2824
            /* Draw major tick labels */
            labelPtr = RbcChainGetValue(linkPtr);
            RbcDrawText(graphPtr->tkwin, drawable, labelPtr->string,
                &axisPtr->tickTextStyle, (int) labelPtr->anchorPos.x,
                (int) labelPtr->anchorPos.y);
        }
    }





    if ((axisPtr->nSegments > 0) && (axisPtr->lineWidth > 0)) {
        /* Draw the tick marks and axis line. */
        RbcDraw2DSegments(graphPtr->display, drawable, axisPtr->tickGC,
            axisPtr->segments, axisPtr->nSegments);
    }
}







>
>
>
>
>







2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
            /* Draw major tick labels */
            labelPtr = RbcChainGetValue(linkPtr);
            RbcDrawText(graphPtr->tkwin, drawable, labelPtr->string,
                &axisPtr->tickTextStyle, (int) labelPtr->anchorPos.x,
                (int) labelPtr->anchorPos.y);
        }
    }
    {
    FILE *f=fopen("rz","a");
    fprintf(f,"ticks=%d %d %d\n",axisPtr->showTicks,axisPtr->nSegments,axisPtr->lineWidth);
    fclose(f);
    }
    if ((axisPtr->nSegments > 0) && (axisPtr->lineWidth > 0)) {
        /* Draw the tick marks and axis line. */
        RbcDraw2DSegments(graphPtr->display, drawable, axisPtr->tickGC,
            axisPtr->segments, axisPtr->nSegments);
    }
}

Changes to generic/rbc/rbcGrMarker.c.

2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
DrawImageMarker(
    RbcMarker * markerPtr,
    Drawable drawable)
{                               /* Pixmap or window to draw into */
    ImageMarker    *imPtr = (ImageMarker *) markerPtr;
    int             width, height;

    /* check if image still exists */
    if ((imPtr->tkImage == NULL) || (RbcImageIsDeleted(imPtr->tkImage))) {
        return;
    }
    if (imPtr->pixmap == None) {
        Pixmap          pixmap;
        Tk_Image        tkImage;







|







2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
DrawImageMarker(
    RbcMarker * markerPtr,
    Drawable drawable)
{                               /* Pixmap or window to draw into */
    ImageMarker    *imPtr = (ImageMarker *) markerPtr;
    int             width, height;

    /* check is image still exists */
    if ((imPtr->tkImage == NULL) || (RbcImageIsDeleted(imPtr->tkImage))) {
        return;
    }
    if (imPtr->pixmap == None) {
        Pixmap          pixmap;
        Tk_Image        tkImage;

Changes to generic/rbc/rbcInt.h.

94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#define RBC_NORMAL_FG_MONO	    "black"
#define RBC_ACTIVE_BG_MONO	    "black"
#define RBC_ACTIVE_FG_MONO	    "white"
#define RBC_SELECT_BG_MONO	    "black"
#define RBC_SELECT_FG_MONO      "black"
#define RBC_SELECT_BORDERWIDTH  "2"
#define RBC_BORDERWIDTH 	    "2"
#define RBC_FONT                "TkDefaultFont 8"
#define RBC_FONT_HUGE           "TkDefaultFontArial 16"
#define RBC_FONT_LARGE          "TkDefaultFontArial 12"
#define RBC_FONT_SMALL          "TkDefaultFontArial 6"
#define RBC_NORMAL_BACKGROUND   "gray85"
#define RBC_NORMAL_FOREGROUND   "black"
#define RBC_ACTIVE_BACKGROUND   "gray64"
#define RBC_ACTIVE_FOREGROUND   "black"
#define RBC_SELECT_BACKGROUND   "lightblue1"
#define RBC_SELECT_FOREGROUND   "black"
#define RBC_INDICATOR_COLOR	    "maroon"






|


|







94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#define RBC_NORMAL_FG_MONO	    "black"
#define RBC_ACTIVE_BG_MONO	    "black"
#define RBC_ACTIVE_FG_MONO	    "white"
#define RBC_SELECT_BG_MONO	    "black"
#define RBC_SELECT_FG_MONO      "black"
#define RBC_SELECT_BORDERWIDTH  "2"
#define RBC_BORDERWIDTH 	    "2"
#define RBC_FONT                "TkDefaultFont 10"
#define RBC_FONT_HUGE           "TkDefaultFontArial 16"
#define RBC_FONT_LARGE          "TkDefaultFontArial 12"
#define RBC_FONT_SMALL          "TkDefaultFontArial 8"
#define RBC_NORMAL_BACKGROUND   "gray85"
#define RBC_NORMAL_FOREGROUND   "black"
#define RBC_ACTIVE_BACKGROUND   "gray64"
#define RBC_ACTIVE_FOREGROUND   "black"
#define RBC_SELECT_BACKGROUND   "lightblue1"
#define RBC_SELECT_FOREGROUND   "black"
#define RBC_INDICATOR_COLOR	    "maroon"

Changes to generic/rbc/rbcWin.h.

53
54
55
56
57
58
59

60
61
62
63
64
65
66
67
68
69
70
..
90
91
92
93
94
95
96






97
98
99
100
101
102
103
104
105
106
107
#ifdef __GNUC__
#include <wingdi.h>
#include <windowsx.h>
#undef Status
#include <winspool.h>
#define Status int


/*
 * Add definitions missing from windgi.h, windowsx.h, and winspool.h
 */
#endif /* __GNUC__ */

/* rbcWinDraw.c */
MODULE_SCOPE int RbcGetPlatformId(
    );
MODULE_SCOPE char *RbcLastError(
    );
MODULE_SCOPE HPALETTE RbcGetSystemPalette(
................................................................................
    Display * display,
    Drawable drawable,
    int x,
    int y,
    double theta,
    RbcTextStyle * stylePtr,
    RbcTextLayout * textPtr);







/* Already defined in rbcInt.h:
void RbcSetDashes(Display *display,
    GC gc,
    RbcDashes *dashesPtr);

*/

#endif /*_RBCWIN*/

/* vim: set ts=4 sw=4 sts=4 ff=unix et : */






>



|







 







>
>
>
>
>
>











53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
..
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#ifdef __GNUC__
#include <wingdi.h>
#include <windowsx.h>
#undef Status
#include <winspool.h>
#define Status int

#endif /* __GNUC__ */
/*
 * Add definitions missing from windgi.h, windowsx.h, and winspool.h
 */
#define XDrawSegments		RbcEmulateXDrawSegments

/* rbcWinDraw.c */
MODULE_SCOPE int RbcGetPlatformId(
    );
MODULE_SCOPE char *RbcLastError(
    );
MODULE_SCOPE HPALETTE RbcGetSystemPalette(
................................................................................
    Display * display,
    Drawable drawable,
    int x,
    int y,
    double theta,
    RbcTextStyle * stylePtr,
    RbcTextLayout * textPtr);
MODULE_SCOPE void RbcEmulateXDrawSegments(
    Display *display,
    Drawable drawable,
    GC gc,
    XSegment *segArr,
    int nSegments);

/* Already defined in rbcInt.h:
void RbcSetDashes(Display *display,
    GC gc,
    RbcDashes *dashesPtr);

*/

#endif /*_RBCWIN*/

/* vim: set ts=4 sw=4 sts=4 ff=unix et : */

Changes to generic/rbc/rbcWinDraw.c.

44
45
46
47
48
49
50







51
52
53
54
55
56
57
58
59
60
61
62
63








64
65
66
67
68
69
70
...
888
889
890
891
892
893
894
895














































































































































896
    Pixmap clip_mask;		/* bitmap clipping; other calls for rects */
    int dash_offset;		/* patterned/dashed line information */
    char dashes;		/* If -1, indicates that the extended
				 * information below is available. */
    int nDashValues;
    char dashValues[12];
} XGCValuesEx;








static Tcl_Encoding systemEncoding = NULL;

static HFONT CreateRotatedFont(
    unsigned long fontId,
    double theta);
static XGCValuesEx *CreateGC();
static BOOL DrawChars(
    HDC dc,
    int x,
    int y,
    char *string,
    int length);









/*
 *--------------------------------------------------------------
 *
 * RbcGetPlatformId --
 *
 *      TODO: Description
................................................................................
        length = Tcl_NumUtfChars(string, -1);
        wstring = (const unsigned short *)Tcl_DStringValue(&dString);
        result = TextOutW(dc, x, y, wstring, length);
        Tcl_DStringFree(&dString);
    }
    return result;
}















































































































































/* vim: set ts=4 sw=4 sts=4 ff=unix et : */






>
>
>
>
>
>
>













>
>
>
>
>
>
>
>







 








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
...
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
    Pixmap clip_mask;		/* bitmap clipping; other calls for rects */
    int dash_offset;		/* patterned/dashed line information */
    char dashes;		/* If -1, indicates that the extended
				 * information below is available. */
    int nDashValues;
    char dashValues[12];
} XGCValuesEx;

typedef struct {
    HDC dc;
    int count;
    COLORREF color;
    int offset, nBits;
} DashInfo;

static Tcl_Encoding systemEncoding = NULL;

static HFONT CreateRotatedFont(
    unsigned long fontId,
    double theta);
static XGCValuesEx *CreateGC();
static BOOL DrawChars(
    HDC dc,
    int x,
    int y,
    char *string,
    int length);
static int GetDashInfo(
    HDC dc,
    GC gc,
    DashInfo *infoPtr);
static void CALLBACK DrawDot(
    int x,
    int y,
    LPARAM clientData);

/*
 *--------------------------------------------------------------
 *
 * RbcGetPlatformId --
 *
 *      TODO: Description
................................................................................
        length = Tcl_NumUtfChars(string, -1);
        wstring = (const unsigned short *)Tcl_DStringValue(&dString);
        result = TextOutW(dc, x, y, wstring, length);
        Tcl_DStringFree(&dString);
    }
    return result;
}

/*
 *----------------------------------------------------------------------
 *
 * RbcEmulateXDrawSegments --
 *
 *      Draws multiple, unconnected lines. For each segment, draws a
 *      line between (x1, y1) and (x2, y2).  It draws the lines in the
 *      order listed in the array of XSegment structures and does not
 *      perform joining at coincident endpoints.  For any given line,
 *      does not draw a pixel more than once. If lines intersect, the
 *      intersecting pixels are drawn multiple times.
 *
 * Results:
 *      None.
 *
 * Side effects:
 *      Draws unconnected line segments on the specified drawable.
 *
 *----------------------------------------------------------------------
 */
void
RbcEmulateXDrawSegments(
    Display *display,
    Drawable drawable,
    GC gc,
    XSegment *segArr,
    int nSegments)
{
    HDC dc;
    register XSegment *segPtr, *endPtr;
    TkWinDCState state;

    display->request++;
    if (drawable == None) {
        return;
    }
    dc = TkWinGetDrawableDC(display, drawable, &state);
    RbcSetROP2(dc, gc->function);
    if (gc->line_style != LineSolid) {
        /* Handle dotted lines specially */
        DashInfo info;

        if (!GetDashInfo(dc, gc, &info)) {
            goto solidLine;
        }
        endPtr = segArr + nSegments;
        for (segPtr = segArr; segPtr < endPtr; segPtr++) {
            info.count = 0; /* Reset dash counter after every segment. */
            LineDDA(segPtr->x1, segPtr->y1, segPtr->x2, segPtr->y2, DrawDot,
                    (LPARAM)&info);
        }
    } else {
        HPEN pen, oldPen;

solidLine:
        pen = RbcGCToPen(dc, gc);
        oldPen = SelectPen(dc, pen);
        endPtr = segArr + nSegments;
        for (segPtr = segArr; segPtr < endPtr; segPtr++) {
            MoveToEx(dc, segPtr->x1, segPtr->y1, (LPPOINT)NULL);
            LineTo(dc, segPtr->x2, segPtr->y2);
        }
        DeletePen(SelectPen(dc, oldPen));
    }
    TkWinReleaseDrawableDC(drawable, dc, &state);
}

/*
 *--------------------------------------------------------------
 *
 * GetDashInfo --
 *
 *      TODO: Description
 *
 * Results:
 *      TODO: Results
 *
 * Side effects:
 *      TODO: Side Effects
 *
 *--------------------------------------------------------------
 */
static int
GetDashInfo(
    HDC dc,
    GC gc,
    DashInfo *infoPtr)
{
    int dashOffset, dashValue;

    dashValue = 0;
    dashOffset = gc->dash_offset;
    if ((int)gc->dashes == -1) {
        XGCValuesEx *gcPtr = (XGCValuesEx *)gc;

        if (gcPtr->nDashValues == 1) {
            dashValue = gcPtr->dashValues[0];
        }
    } else if (gc->dashes > 0) {
        dashValue = (int)gc->dashes;
    }
    if (dashValue == 0) {
        return FALSE;
    }
    infoPtr->dc = dc;
    infoPtr->nBits = dashValue;
    infoPtr->offset = dashOffset;
    infoPtr->count = 0;
    infoPtr->color = gc->foreground;
    return TRUE;
}

/*
 *----------------------------------------------------------------------
 *
 * DrawDot --
 *
 *      Draws a dot.
 *
 * Results:
 *      None.
 *
 * Side effects:
 *      Renders a dot.
 *
 *----------------------------------------------------------------------
 */
static void CALLBACK DrawDot(
    int x, /* y-coordinates of point */
    int y, /* y-coordinates of point */
    LPARAM clientData)
{				/* Line information */
    DashInfo *infoPtr = (DashInfo *) clientData;
    int count;

    infoPtr->count++;
    count = (infoPtr->count + infoPtr->offset) / infoPtr->nBits;
    if (count & 0x1) {
        SetPixelV(infoPtr->dc, x, y, infoPtr->color);
    }
}

/* vim: set ts=4 sw=4 sts=4 ff=unix et : */