2015-09-04 13:51:10 -05:00
|
|
|
// 4 september 2015
|
|
|
|
|
|
|
|
typedef struct uiArea uiArea;
|
|
|
|
typedef struct uiAreaHandler uiAreaHandler;
|
|
|
|
typedef struct uiAreaDrawParams uiAreaDrawParams;
|
|
|
|
|
2015-09-06 15:55:43 -05:00
|
|
|
typedef struct uiDrawContext uiDrawContext;
|
|
|
|
|
2015-09-04 13:51:10 -05:00
|
|
|
struct uiAreaHandler {
|
2015-09-06 15:20:37 -05:00
|
|
|
void (*Draw)(uiAreaHandler *, uiArea *, uiAreaDrawParams *);
|
2015-09-05 19:05:48 -05:00
|
|
|
uintmax_t (*HScrollMax)(uiAreaHandler *, uiArea *);
|
|
|
|
uintmax_t (*VScrollMax)(uiAreaHandler *, uiArea *);
|
2015-09-04 13:51:10 -05:00
|
|
|
};
|
|
|
|
|
2015-09-06 15:20:37 -05:00
|
|
|
struct uiAreaDrawParams {
|
2015-09-06 15:55:43 -05:00
|
|
|
uiDrawContext *Context;
|
2015-09-06 15:20:37 -05:00
|
|
|
|
|
|
|
intmax_t ClientWidth;
|
|
|
|
intmax_t ClientHeight;
|
|
|
|
|
|
|
|
intmax_t ClipX;
|
|
|
|
intmax_t ClipY;
|
|
|
|
intmax_t ClipWidth;
|
|
|
|
intmax_t ClipHeight;
|
|
|
|
|
2015-09-06 15:55:43 -05:00
|
|
|
int DPIX;
|
|
|
|
int DPIY;
|
2015-09-06 15:20:37 -05:00
|
|
|
|
|
|
|
intmax_t HScrollPos;
|
|
|
|
intmax_t VScrollPos;
|
|
|
|
};
|
2015-09-06 19:02:01 -05:00
|
|
|
|
2015-09-06 21:48:25 -05:00
|
|
|
// TODO proper sources
|
2015-09-06 19:02:01 -05:00
|
|
|
// TODO dotting/dashing
|
|
|
|
|
|
|
|
typedef struct uiDrawStrokeParams uiDrawStrokeParams;
|
|
|
|
typedef enum uiDrawLineCap uiDrawLineCap;
|
|
|
|
typedef enum uiDrawLineJoin uiDrawLineJoin;
|
2015-09-06 21:48:25 -05:00
|
|
|
typedef enum uiDrawFillMode uiDrawFillMode;
|
2015-09-06 19:02:01 -05:00
|
|
|
|
|
|
|
enum uiDrawLineCap {
|
|
|
|
uiDrawLineCapFlat,
|
|
|
|
uiDrawLineCapRound,
|
|
|
|
uiDrawLineCapSquare,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum uiDrawLineJoin {
|
|
|
|
uiDrawLineJoinMiter,
|
|
|
|
uiDrawLineJoinRound,
|
|
|
|
uiDrawLineJoinBevel,
|
|
|
|
};
|
|
|
|
|
2015-09-06 21:48:25 -05:00
|
|
|
// this is the default for botoh cairo and GDI
|
|
|
|
// Core Graphics doesn't explicitly specify a default, but NSBezierPath allows you to choose one, and this is the initial value
|
|
|
|
// so we're good to use it too!
|
|
|
|
#define uiDrawDefaultMiterLimit 10.0
|
|
|
|
|
|
|
|
enum uiDrawFillMode {
|
|
|
|
uiDrawFillModeWinding,
|
2015-09-07 09:25:59 -05:00
|
|
|
// TODO rename to EvenOdd?
|
2015-09-06 21:48:25 -05:00
|
|
|
uiDrawFillModeAlternate,
|
|
|
|
};
|
|
|
|
|
2015-09-06 19:02:01 -05:00
|
|
|
struct uiDrawStrokeParams {
|
|
|
|
uiDrawLineCap Cap;
|
|
|
|
uiDrawLineJoin Join;
|
|
|
|
intmax_t Thickness;
|
2015-09-06 21:48:25 -05:00
|
|
|
double MiterLimit;
|
|
|
|
};
|
|
|
|
|
2015-09-07 09:13:15 -05:00
|
|
|
void uiDrawBeginPathRGB(uiDrawContext *, uint8_t, uint8_t, uint8_t);
|
2015-09-08 22:00:13 -05:00
|
|
|
// TODO verify these aren't alpha premultiplied anywhere
|
2015-09-07 09:25:59 -05:00
|
|
|
void uiDrawBeginPathRGBA(uiDrawContext *, uint8_t, uint8_t, uint8_t, uint8_t);
|
2015-09-06 19:02:01 -05:00
|
|
|
|
|
|
|
void uiDrawMoveTo(uiDrawContext *, intmax_t, intmax_t);
|
|
|
|
void uiDrawLineTo(uiDrawContext *, intmax_t, intmax_t);
|
2015-09-07 09:25:59 -05:00
|
|
|
void uiDrawRectangle(uiDrawContext *, intmax_t, intmax_t, intmax_t, intmax_t);
|
2015-09-07 14:34:14 -05:00
|
|
|
// notes: angles are both relative to 0 and go counterclockwise
|
2015-09-08 15:28:08 -05:00
|
|
|
void uiDrawArcTo(uiDrawContext *, intmax_t, intmax_t, intmax_t, double, double, int);
|
2015-09-07 18:29:42 -05:00
|
|
|
// TODO behavior when there is no initial point on Windows and OS X
|
|
|
|
void uiDrawBezierTo(uiDrawContext *, intmax_t, intmax_t, intmax_t, intmax_t, intmax_t, intmax_t);
|
2015-09-06 21:48:25 -05:00
|
|
|
void uiDrawCloseFigure(uiDrawContext *);
|
2015-09-07 09:13:15 -05:00
|
|
|
|
2015-09-06 19:02:01 -05:00
|
|
|
void uiDrawStroke(uiDrawContext *, uiDrawStrokeParams *);
|
2015-09-07 09:25:59 -05:00
|
|
|
void uiDrawFill(uiDrawContext *, uiDrawFillMode);
|
2015-09-06 22:37:05 -05:00
|
|
|
|
|
|
|
// path functions
|
|
|
|
// cairo gdi core graphics
|
|
|
|
// move_to MoveToEx MoveToPoint
|
|
|
|
// line_to LineTo AddLineToPoint
|
2015-09-07 14:34:14 -05:00
|
|
|
// arc Arc/ArcTo/AngleArc/Pie AddArc/AddArcToPoint/AddEllipseInRect
|
|
|
|
// arc_negative Arc/ArcTo/AngleArc/Pie AddArc/AddArcToPoint
|
2015-09-06 22:37:05 -05:00
|
|
|
// curve_to PolyBezier/PolyBezierTo AddCurveToPoint
|
|
|
|
// rectangle Rectangle AddRect
|
|
|
|
// [arc functions?] Chord [arc functions?]
|
|
|
|
// [combination] RoundRect [same way as cairo?]
|
|
|
|
// [TODO pango] TextOut/ExtTextOut [TODO core text]
|
|
|
|
// [TODO] [TODO] AddQuadCurveToPoint
|
|
|
|
|
|
|
|
// on sources:
|
|
|
|
// cairo:
|
|
|
|
// - RGB
|
|
|
|
// - RGBA
|
|
|
|
// - images
|
|
|
|
// - linear gradients, RGB or RGBA
|
|
|
|
// - rounded gradients, RGB or RGBA
|
|
|
|
// gdi:
|
|
|
|
// - RGB
|
|
|
|
// - hatches
|
|
|
|
// - images
|
|
|
|
// we can create a linear gradient image, but RGB only, and of finite size
|
|
|
|
// core graphics:
|
|
|
|
// - arbitrary patterns
|
|
|
|
// - solid colors, arbitrary spaces
|
|
|
|
// - shadows
|
2015-09-07 14:34:14 -05:00
|
|
|
|
|
|
|
// arcs
|
|
|
|
// cairo_arc/arc_negative
|
|
|
|
// - parameters: center, radius, angle1 radians, angle2 radins
|
|
|
|
// - if angle2 < angle1, TODO
|
|
|
|
// - if angle2 > angle1, TODO
|
|
|
|
// - line segment from current point to beginning of arc
|
|
|
|
// - arc: clockwise, arc_negative: counterclockwise
|
|
|
|
// - circular
|
|
|
|
// GDI Arc/Pie
|
|
|
|
// - parameters: bounding box, start point, end point
|
|
|
|
// - current position not used/changed
|
|
|
|
// - either clockwise or counterclockwise
|
|
|
|
// - elliptical
|
|
|
|
// GDI ArcTo
|
|
|
|
// - same as Arc except line segment from current point to beginning of arc
|
|
|
|
// - there does not appear to be a PieTo
|
|
|
|
// GDI AngleArc
|
|
|
|
// - parameters: center, radius, angle1 degrees, angle2 degrees
|
|
|
|
// - line segment from current position to beginning of arc
|
|
|
|
// - counterclockwise
|
|
|
|
// - circular
|
|
|
|
// - can be used to draw pies too; MSDN example demonstrates
|