/usr/include/ipeattributes.h is in libipe-dev 7.1.4-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 | // -*- C++ -*-
// --------------------------------------------------------------------
// Ipe object attributes
// --------------------------------------------------------------------
/*
This file is part of the extensible drawing editor Ipe.
Copyright (C) 1993-2013 Otfried Cheong
Ipe is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
As a special exception, you have permission to link Ipe with the
CGAL library and distribute executables, as long as you follow the
requirements of the Gnu General Public License in regard to all of
the software in the executable aside from CGAL.
Ipe is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
License for more details.
You should have received a copy of the GNU General Public License
along with Ipe; if not, you can find it at
"http://www.gnu.org/copyleft/gpl.html", or write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef IPEATTRIBUTES_H
#define IPEATTRIBUTES_H
#include "ipebase.h"
#include "ipegeo.h"
// --------------------------------------------------------------------
namespace ipe {
/*! \brief The different kinds of attributes.
\ingroup attr
The same symbolic attribute (say "normal") has a different value
in the StyleSheet depending on the Kind of attribute. The main use
for Kind is as an argument to StyleSheet::find.
ESymbol, EGradient, ETiling, and EEffect have their own lookup
methods in the StyleSheet. The values are still useful as an
argument to allNames(), has(), and findDefinition().
*/
enum Kind { EPen = 0, ESymbolSize, EArrowSize, EColor,
EDashStyle, ETextSize, ETextStretch, ETextStyle,
EGridSize, EAngleSize, EOpacity, ETiling,
ESymbol, EGradient, EEffect };
/*! \ingroup attr */
extern const char * const kind_names[];
/*! \brief A Property identifies an attribute that an object can have.
\ingroup attr
The Property identifies a unique attribute of an object, while
different Property values can be of the same ipe::Kind. For
instance, both EPropStrokeColor and EPropFillColor identify an
Attribute of Kind EColor.
*/
enum Property { EPropPen = 0, EPropSymbolSize,
EPropFArrow, EPropRArrow,
EPropFArrowSize, EPropRArrowSize,
EPropFArrowShape, EPropRArrowShape,
EPropStrokeColor, EPropFillColor, EPropMarkShape,
EPropPathMode, EPropDashStyle,
EPropTextSize, EPropTextStyle,
EPropOpacity, EPropTiling, EPropGradient,
EPropHorizontalAlignment, EPropVerticalAlignment,
EPropLineJoin, EPropLineCap, EPropFillRule,
EPropPinned, EPropTransformations,
EPropTransformableText,
EPropMinipage, EPropWidth,
};
/*! \ingroup attr */
extern const char * const property_names[];
//! Path mode (stroked, filled, or both).
/*! \ingroup attr */
enum TPathMode { EStrokedOnly, EStrokedAndFilled, EFilledOnly };
//! Horizontal alignment.
/*! \ingroup attr */
enum THorizontalAlignment { EAlignLeft, EAlignRight, EAlignHCenter };
//! Vertical alignment.
/*! \ingroup attr */
enum TVerticalAlignment { EAlignBottom, EAlignBaseline,
EAlignTop, EAlignVCenter };
//! Line join style.
/*! \ingroup attr */
/*! The EDefaultJoin means to use the setting from the style sheet. */
enum TLineJoin { EDefaultJoin, EMiterJoin, ERoundJoin, EBevelJoin };
//! Line cap style.
/*! \ingroup attr */
/*! The EDefaultCap means to use the setting from the style sheet. */
enum TLineCap { EDefaultCap, EButtCap, ERoundCap, ESquareCap };
//! Fill rule.
/*! \ingroup attr */
/*! The EDefaultRule means to use the setting from the style sheet. */
enum TFillRule { EDefaultRule, EWindRule, EEvenOddRule };
//! Pinning status of objects.
/*! \ingroup attr */
enum TPinned { ENoPin = 0x00, EHorizontalPin = 0x01,
EVerticalPin = 0x02, EFixedPin = 0x03 };
//! Transformations that are permitted for an object.
/*! \ingroup attr */
enum TTransformations { ETransformationsTranslations,
ETransformationsRigidMotions,
ETransformationsAffine };
//! Selection status of an object on the page
/*! \ingroup attr */
enum TSelect { ENotSelected = 0, EPrimarySelected, ESecondarySelected };
// --------------------------------------------------------------------
class Color {
public:
//! Default constructor.
Color() { /* nothing */ }
explicit Color(String str);
explicit Color(int r, int g, int b);
void save(Stream &stream) const;
void saveRGB(Stream &stream) const;
bool isGray() const;
bool operator==(const Color &rhs) const;
inline bool operator!=(const Color &rhs) const {return !(*this == rhs); }
public:
Fixed iRed, iGreen, iBlue;
};
//! A tiling pattern.
/*! \ingroup attr */
struct Tiling {
Angle iAngle;
double iStep;
double iWidth;
};
//! A gradient pattern.
/*! \ingroup attr */
struct Gradient {
//! A color stop.
struct Stop {
//! Offset between 0.0 and 1.0.
double offset;
//! The color at this offset.
Color color;
};
//! There are two types of gradients, along an axis or between two circles.
enum TType { EAxial = 2, ERadial = 3 };
//! The type of gradient: axial or radial.
TType iType;
//! The coordinates of the axis endpoints, or the two circle centers.
Vector iV[2];
//! The radii of the two circles (not used for axial gradients).
double iRadius[2];
//! Whether to extend the gradient beyond the endpoints.
bool iExtend;
//! Gradient transformation.
Matrix iMatrix;
//! The color stops.
std::vector<Stop> iStops;
};
//! Layout of a Page.
/*! \ingroup attr */
struct Layout {
//! Create null layout.
Layout() { iPaperSize.x = -1.0; }
//! Is this an undefined (null) layout?
bool isNull() const { return iPaperSize.x < 0.0; }
//! Return rectangle describing the paper.
Rect paper() const { return Rect(-iOrigin, iPaperSize - iOrigin); }
//! Dimensions of the media.
Vector iPaperSize;
//! Origin of the Ipe coordinate system relative to the paper.
Vector iOrigin;
//! Size of the frame (the drawing area).
Vector iFrameSize;
//! Paragraph skip (between textboxes).
double iParagraphSkip;
//! Crop paper to drawing.
bool iCrop;
};
//! Padding for text bounding box.
/*! \ingroup attr */
struct TextPadding {
public:
double iLeft, iRight, iTop, iBottom;
};
struct Effect {
public:
//! The various fancy effects that Acrobat Reader will show.
enum TEffect {
ENormal, ESplitHI, ESplitHO, ESplitVI, ESplitVO,
EBlindsH, EBlindsV, EBoxI, EBoxO,
EWipeLR, EWipeBT, EWipeRL, EWipeTB,
EDissolve, EGlitterLR, EGlitterTB, EGlitterD };
Effect();
void pageDictionary(Stream &stream) const;
public:
TEffect iEffect;
int iTransitionTime;
int iDuration;
};
// --------------------------------------------------------------------
class Repository {
public:
static Repository *get();
static void cleanup();
String toString(int index) const;
int toIndex(String str);
// int getIndex(String str) const;
private:
Repository();
static Repository *singleton;
std::vector<String> iStrings;
};
// --------------------------------------------------------------------
class Attribute {
enum { EMiniMask = 0xc0000000, ETypeMask = 0xe0000000,
ESymbolic = 0x80000000, EFixed = 0x40000000,
EAbsolute = 0xc0000000, EEnum = 0xe0000000,
EFixedMask = 0x3fffffff, ENameMask = 0x1fffffff,
EWhiteValue = ((1000 << 20) + (1000 << 10) + 1000),
EOneValue = EFixed|1000 };
public:
//! Default constructor.
explicit Attribute() { /* nothing */ }
explicit Attribute(bool symbolic, String name);
explicit Attribute(Fixed value);
explicit Attribute(Color color);
static Attribute Boolean(bool flag) { return Attribute(EEnum + flag); }
explicit Attribute(THorizontalAlignment align) { iName = EEnum + align +2; }
explicit Attribute(TVerticalAlignment align) { iName = EEnum + align + 5; }
explicit Attribute(TLineJoin join) { iName = EEnum + join + 9; }
explicit Attribute(TLineCap cap) { iName = EEnum + cap + 13; }
explicit Attribute(TFillRule rule) { iName = EEnum + rule + 17; }
explicit Attribute(TPinned pin) { iName = EEnum + pin + 20; }
explicit Attribute(TTransformations trans) { iName = EEnum + trans + 24; }
explicit Attribute(TPathMode pm) { iName = EEnum + pm + 27; }
//! Is it symbolic?
inline bool isSymbolic() const {
return ((iName & ETypeMask) == ESymbolic); }
//! Is it an absolute string value?
inline bool isString() const {
return ((iName & ETypeMask) == EAbsolute); }
//! Is it a color?
inline bool isColor() const {
return ((iName & EMiniMask) == 0); }
//! Is it a number?
inline bool isNumber() const {
return ((iName & EMiniMask) == EFixed); }
//! Is it an enumeration?
inline bool isEnum() const {
return ((iName & ETypeMask) == EEnum); }
//! Is it a boolean?
inline bool isBoolean() const {
return (isEnum() && 0 <= index() && index() <= 1); }
//! Is it the symbolic name "normal"?
inline bool isNormal() const { return (iName == ESymbolic); }
//! Return index into Repository.
inline int index() const { return iName & ENameMask; }
int internal() const { return iName; }
String string() const;
Fixed number() const;
Color color() const;
bool boolean() const { return bool(index()); }
THorizontalAlignment horizontalAlignment() const {
return THorizontalAlignment(index() - 2); }
TVerticalAlignment verticalAlignment() const {
return TVerticalAlignment(index() - 5); }
TLineJoin lineJoin() const {return TLineJoin(index() - 9); }
TLineCap lineCap() const { return TLineCap(index() - 13); }
TFillRule fillRule() const { return TFillRule(index() - 17); }
TPinned pinned() const { return TPinned(index() - 20); }
TTransformations transformations() const {
return TTransformations(index() - 24); }
TPathMode pathMode() const { return TPathMode(index() - 27); }
//! Are two values equal (only compares index!)
inline bool operator==(const Attribute &rhs) const {
return iName == rhs.iName; }
//! Are two values different (only compares index!)
inline bool operator!=(const Attribute &rhs) const {
return iName != rhs.iName; }
//! Create absolute black color.
inline static Attribute BLACK() { return Attribute(0); }
//! Create absolute white color.
inline static Attribute WHITE() { return Attribute(EWhiteValue); }
//! Create absolute number one.
inline static Attribute ONE() { return Attribute(EOneValue); }
//! Create symbolic attribute "normal".
inline static Attribute NORMAL() { return Attribute(ESymbolic); }
//! Create symbolic attribute "undefined"
inline static Attribute UNDEFINED() { return Attribute(ESymbolic + 1); }
//! Create symbolic attribute "Background"
inline static Attribute BACKGROUND() { return Attribute(ESymbolic + 2); }
//! Create symbolic attribute "sym-stroke"
inline static Attribute SYM_STROKE() { return Attribute(ESymbolic + 3); }
//! Create symbolic attribute "sym-fill"
inline static Attribute SYM_FILL() { return Attribute(ESymbolic + 4); }
//! Create symbolic attribute "sym-pen"
inline static Attribute SYM_PEN() { return Attribute(ESymbolic + 5); }
//! Create symbolic attribute "arrow/normal(spx)"
inline static Attribute ARROW_NORMAL() { return Attribute(ESymbolic + 6); }
//! Create symbolic attribute "opaque"
inline static Attribute OPAQUE() { return Attribute(ESymbolic + 7); }
//! Create symbolic attribute "arrow/arc(spx)"
inline static Attribute ARROW_ARC() { return Attribute(ESymbolic + 8); }
//! Create symbolic attribute "arrow/farc(spx)"
inline static Attribute ARROW_FARC() { return Attribute(ESymbolic + 9); }
static Attribute makeColor(String str, Attribute deflt);
static Attribute makeScalar(String str, Attribute deflt);
static Attribute makeDashStyle(String str);
static Attribute makeTextSize(String str);
static Attribute normal(Kind kind);
private:
inline Attribute(int index) : iName(index) { /* nothing */ }
explicit Attribute(bool symbolic, int index);
private:
unsigned int iName;
friend class StyleSheet;
};
/*! \var AttributeSeq
\ingroup attr
\brief A sequence of attribute values.
*/
typedef std::vector<Attribute> AttributeSeq;
// --------------------------------------------------------------------
class AllAttributes {
public:
AllAttributes();
TPathMode iPathMode; //!< Should we stroke and/or fill?
Attribute iStroke; //!< Stroke color.
Attribute iFill; //!< Fill color.
Attribute iDashStyle; //!< Dash style.
Attribute iPen; //!< Pen (that is, line width).
bool iFArrow; //!< Arrow forward?
bool iRArrow; //!< Reverse arrow?
Attribute iFArrowShape; //!< Shape of forward arrows
Attribute iRArrowShape; //!< Shape of reverse arrows
Attribute iFArrowSize; //!< Forward arrow size.
Attribute iRArrowSize; //!< Reverse arrow size.
Attribute iSymbolSize; //!< Symbol size.
Attribute iTextSize; //!< Text size.
//! Horizontal alignment of label objects.
THorizontalAlignment iHorizontalAlignment;
//! Vertical alignment of label objects.
TVerticalAlignment iVerticalAlignment;
Attribute iTextStyle; //!< Text style.
TPinned iPinned; //!< Pinned status.
//! Should newly created text be transformable?
/*! If this is false, newly created text will only allow
translations. Otherwise, the value of iTranslations is used (as
for other objects). */
bool iTransformableText;
//! Allowed transformations.
TTransformations iTransformations;
TLineJoin iLineJoin; //!< Line join style.
TLineCap iLineCap; //!< Line cap style.
TFillRule iFillRule; //!< Shape fill rule.
Attribute iOpacity; //!< Opacity.
Attribute iTiling; //!< Tiling pattern.
Attribute iGradient; //!< Gradient pattern.
Attribute iMarkShape; //!< Shape of Mark to create.
};
// --------------------------------------------------------------------
/*! \relates Color */
inline Stream &operator<<(Stream &stream, const Color &attr)
{
attr.save(stream); return stream;
}
} // namespace
// --------------------------------------------------------------------
#endif
|