Something went wrong. Try again.
Reactos
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395/* * GdiPlusPen.h * * Windows GDI+ * * This file is part of the w32api package. * * THIS SOFTWARE IS NOT COPYRIGHTED * * This source code is offered for use in the public domain. You may * use, modify or distribute it freely. * * This code is distributed in the hope that it will be useful but * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY * DISCLAIMED. This includes but is not limited to warranties of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */
#ifndef _GDIPLUSPEN_H#define _GDIPLUSPEN_H
class Pen : public GdiplusBase{ public: friend class Graphics; friend class GraphicsPath;
Pen(const Brush *brush, REAL width = 1.0f) : nativePen(NULL) { lastStatus = DllExports::GdipCreatePen2(getNat(brush), width, UnitWorld, &nativePen); }
Pen(const Color &color, REAL width = 1.0f) : nativePen(NULL) { lastStatus = DllExports::GdipCreatePen1(color.GetValue(), width, UnitWorld, &nativePen); }
~Pen() { DllExports::GdipDeletePen(nativePen); }
Pen * Clone() { GpPen *clonePen = NULL; SetStatus(DllExports::GdipClonePen(nativePen, &clonePen)); if (lastStatus != Ok) return NULL; Pen *newPen = new Pen(clonePen, lastStatus); if (!newPen) DllExports::GdipDeletePen(clonePen); return newPen; }
PenAlignment GetAlignment() { PenAlignment penAlignment; SetStatus(DllExports::GdipGetPenMode(nativePen, &penAlignment)); return penAlignment; }
Brush * GetBrush() { // FIXME return NULL; }
Status GetColor(Color *color) { if (!color) return SetStatus(InvalidParameter);
ARGB argb; SetStatus(DllExports::GdipGetPenColor(nativePen, &argb)); color->SetValue(argb); return lastStatus; }
Status GetCompoundArray(REAL *compoundArray, INT count) { if (!compoundArray || count <= 0) return SetStatus(InvalidParameter);#if 1 return SetStatus(NotImplemented);#else return SetStatus(DllExports::GdipGetPenCompoundArray(nativePen, compoundArray, count));#endif }
INT GetCompoundArrayCount() { INT count = 0; SetStatus(DllExports::GdipGetPenCompoundCount(nativePen, &count)); return count; }
Status GetCustomEndCap(CustomLineCap *customCap) { if (!customCap) return SetStatus(InvalidParameter);
return SetStatus(DllExports::GdipGetPenCustomEndCap(nativePen, &getNat(customCap))); }
Status GetCustomStartCap(CustomLineCap *customCap) { if (!customCap) return SetStatus(InvalidParameter);
return SetStatus(DllExports::GdipGetPenCustomStartCap(nativePen, &getNat(customCap))); }
DashCap GetDashCap() { DashCap dashCap; SetStatus(DllExports::GdipGetPenDashCap197819(nativePen, &dashCap)); return dashCap; }
REAL GetDashOffset() { REAL offset; SetStatus(DllExports::GdipGetPenDashOffset(nativePen, &offset)); return offset; }
Status GetDashPattern(REAL *dashArray, INT count) { if (dashArray == NULL || count <= 0) return SetStatus(InvalidParameter);
return SetStatus(DllExports::GdipGetPenDashArray(nativePen, dashArray, count)); }
INT GetDashPatternCount() { INT count = 0; SetStatus(DllExports::GdipGetPenDashCount(nativePen, &count)); return count; }
DashStyle GetDashStyle() { DashStyle dashStyle; SetStatus(DllExports::GdipGetPenDashStyle(nativePen, &dashStyle)); return dashStyle; }
LineCap GetEndCap() { LineCap endCap; SetStatus(DllExports::GdipGetPenEndCap(nativePen, &endCap)); return endCap; }
Status GetLastStatus() const { return lastStatus; }
LineJoin GetLineJoin() { LineJoin lineJoin; SetStatus(DllExports::GdipGetPenLineJoin(nativePen, &lineJoin)); return lineJoin; }
REAL GetMiterLimit() { REAL miterLimit; SetStatus(DllExports::GdipGetPenMiterLimit(nativePen, &miterLimit)); return miterLimit; }
PenType GetPenType() { PenType type; SetStatus(DllExports::GdipGetPenFillType(nativePen, &type)); return type; }
LineCap GetStartCap() { LineCap startCap; SetStatus(DllExports::GdipGetPenStartCap(nativePen, &startCap)); return startCap; }
Status GetTransform(Matrix *matrix) { return SetStatus(DllExports::GdipGetPenTransform(nativePen, getNat(matrix))); }
REAL GetWidth() { REAL width; SetStatus(DllExports::GdipGetPenWidth(nativePen, &width)); return width; }
Status MultiplyTransform(Matrix *matrix, MatrixOrder order = MatrixOrderPrepend) { return SetStatus(DllExports::GdipMultiplyPenTransform(nativePen, getNat(matrix), order)); }
Status ResetTransform() { return SetStatus(DllExports::GdipResetPenTransform(nativePen)); }
Status RotateTransform(REAL angle, MatrixOrder order = MatrixOrderPrepend) { return SetStatus(DllExports::GdipRotatePenTransform(nativePen, angle, order)); }
Status ScaleTransform(REAL sx, REAL sy, MatrixOrder order = MatrixOrderPrepend) { return SetStatus(DllExports::GdipScalePenTransform(nativePen, sx, sy, order)); }
Status SetAlignment(PenAlignment penAlignment) { return SetStatus(DllExports::GdipSetPenMode(nativePen, penAlignment)); }
Status SetBrush(const Brush *brush) { GpBrush *theBrush = brush ? getNat(brush) : NULL; return SetStatus(DllExports::GdipSetPenBrushFill(nativePen, theBrush)); }
Status SetColor(const Color &color) { return SetStatus(DllExports::GdipSetPenColor(nativePen, color.GetValue())); }
Status SetCompoundArray(const REAL *compoundArray, INT count) { return SetStatus(DllExports::GdipSetPenCompoundArray(nativePen, compoundArray, count)); }
Status SetCustomEndCap(const CustomLineCap *customCap) { GpCustomLineCap *cap = customCap ? getNat(customCap) : NULL; return SetStatus(DllExports::GdipSetPenCustomEndCap(nativePen, cap)); }
Status SetCustomStartCap(const CustomLineCap *customCap) { GpCustomLineCap *cap = customCap ? getNat(customCap) : NULL; return SetStatus(DllExports::GdipSetPenCustomStartCap(nativePen, cap)); }
Status SetDashCap(DashCap dashCap) { return SetStatus(DllExports::GdipSetPenDashCap197819(nativePen, dashCap)); }
Status SetDashOffset(REAL dashOffset) { return SetStatus(DllExports::GdipSetPenDashOffset(nativePen, dashOffset)); }
Status SetDashPattern(const REAL *dashArray, INT count) { return SetStatus(DllExports::GdipSetPenDashArray(nativePen, dashArray, count)); }
Status SetDashStyle(DashStyle dashStyle) { return SetStatus(DllExports::GdipSetPenDashStyle(nativePen, dashStyle)); }
Status SetEndCap(LineCap endCap) { return SetStatus(DllExports::GdipSetPenEndCap(nativePen, endCap)); }
Status SetLineCap(LineCap startCap, LineCap endCap, DashCap dashCap) { return SetStatus(DllExports::GdipSetPenLineCap197819(nativePen, startCap, endCap, dashCap)); }
Status SetLineJoin(LineJoin lineJoin) { return SetStatus(DllExports::GdipSetPenLineJoin(nativePen, lineJoin)); }
Status SetMiterLimit(REAL miterLimit) { return SetStatus(DllExports::GdipSetPenMiterLimit(nativePen, miterLimit)); }
Status SetStartCap(LineCap startCap) { return SetStatus(DllExports::GdipSetPenStartCap(nativePen, startCap)); }
Status SetTransform(const Matrix *matrix) { GpMatrix *mat = matrix ? getNat(matrix) : NULL; return SetStatus(DllExports::GdipSetPenTransform(nativePen, mat)); }
Status SetWidth(REAL width) { return SetStatus(DllExports::GdipSetPenWidth(nativePen, width)); }
Status TranslateTransform(REAL dx, REAL dy, MatrixOrder order = MatrixOrderPrepend) { return SetStatus(DllExports::GdipTranslatePenTransform(nativePen, dx, dy, order)); }
protected: GpPen *nativePen; mutable Status lastStatus;
Status SetStatus(Status status) const { if (status != Ok) lastStatus = status; return status; }
Pen(GpPen *pen, Status status) : nativePen(pen), lastStatus(status) { }
VOID SetNativePen(GpPen *pen) { nativePen = pen; }
private: // Pen is not copyable Pen(const Pen &); Pen & operator=(const Pen &);
// get native friend inline GpPen *& getNat(const Pen *pen) { return const_cast<Pen *>(pen)->nativePen; }};
#endif /* _GDIPLUSPEN_H */