BPicture: Fix archive constructor.
[haiku.git] / src / kits / locale / FormatParameters.cpp
blob871fa6e52421dea7331e7d1b94fefb8f9aeed9dd
1 #include <FormatParameters.h>
3 // defaults
4 static const format_alignment kDefaultAlignment = B_ALIGN_FORMAT_RIGHT;
5 static const size_t kDefaultFormatWidth = 1;
7 // flags
8 enum {
9 ALIGNMENT_SET = 0x01,
10 WIDTH_SET = 0x02,
13 // constructor
14 BFormatParameters::BFormatParameters(const BFormatParameters *parent)
15 : fParent(parent),
16 fFlags(0)
20 // copy constructor
21 BFormatParameters::BFormatParameters(const BFormatParameters &other)
22 : fParent(other.fParent),
23 fAlignment(other.fAlignment),
24 fWidth(other.fWidth),
25 fFlags(other.fFlags)
29 // destructor
30 BFormatParameters::~BFormatParameters()
34 // SetAlignment
35 void
36 BFormatParameters::SetAlignment(format_alignment alignment)
38 fAlignment = alignment;
39 fFlags |= ALIGNMENT_SET;
42 // Alignment
43 format_alignment
44 BFormatParameters::Alignment() const
46 if (fFlags & ALIGNMENT_SET)
47 return fAlignment;
48 if (fParent)
49 return fParent->Alignment();
50 return kDefaultAlignment;
53 // SetFormatWidth
54 void
55 BFormatParameters::SetFormatWidth(size_t width)
57 fWidth = width;
58 fFlags |= WIDTH_SET;
61 // FormatWidth
62 size_t
63 BFormatParameters::FormatWidth() const
65 if (fFlags & WIDTH_SET)
66 return fWidth;
67 if (fParent)
68 return fParent->FormatWidth();
69 return kDefaultFormatWidth;
72 // SetParentParameters
73 void
74 BFormatParameters::SetParentParameters(const BFormatParameters *parent)
76 fParent = parent;
79 // ParentParameters
80 const BFormatParameters *
81 BFormatParameters::ParentParameters() const
83 return fParent;
86 // =
87 BFormatParameters &
88 BFormatParameters::operator=(const BFormatParameters &other)
90 fParent = other.fParent;
91 fAlignment = other.fAlignment;
92 fWidth = other.fWidth;
93 fFlags = other.fFlags;
94 return *this;