summaryrefslogtreecommitdiffstats
path: root/kugar/lib/mreportsection.h
blob: 1121e010673f4128f2869eb8f3d6d49df93a3ba2 (plain)
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
/***************************************************************************
             mreportsection.h  -  Kugar report section
             -------------------
   begin     : Mon Aug 23 1999
   copyright : (C) 1999 by Mutiny Bay Software
   email     : info@mutinybaysoftware.com
   copyright : (C) 2002-2004 Alexander Dymo
   email     : cloudtemple@mksat.net
***************************************************************************/

#ifndef MREPORTSECTION_H
#define MREPORTSECTION_H

#include <tqptrlist.h>
#include <tqobject.h>

#include "mlineobject.h"
#include "mlabelobject.h"
#include "mspecialobject.h"
#include "mcalcobject.h"
#include "mfieldobject.h"

/**Kugar report section
  *@author Mutiny Bay Software
  */

namespace Kugar
{

class MReportSection : public TQObject
{

public:
    /** Section print frequency constants */
    enum PrintFrequency { FirstPage = 0, EveryPage, LastPage };

    /** Constructor */
    MReportSection();
    /** Copy constructor */
    MReportSection( const MReportSection& mReportSection );
    /** Assignment operator */
    MReportSection operator=( const MReportSection& mReportSection );
    /** Destructor */
    virtual ~MReportSection();

protected:
    /** Sections's height */
    int height;
    /** Sections's level in hierarchy */
    int level;
    /** Section print frequency */
    int frequency;
    /** Page number - used by special fields */
    int pageNumber;
    /** Report date - used by special fields */
    TQDate reportDate;

    /** Section's line collection */
    TQPtrList<MLineObject> lines;
    /** Section's label collection */
    TQPtrList<MLabelObject> labels;
    /** Section's special field collection */
    TQPtrList<MSpecialObject> specialFields;
    /** Section's calculated field collection */
    TQPtrList<MCalcObject> calculatedFields;
    /** Section's field collection (for use as report variables) */
    TQPtrList<MFieldObject> fields;

public:
    /** Adds a new line object to the section's line collection */
    void addLine( MLineObject* line );
    /** Adds a new label object to the section's label collection */
    void addLabel( MLabelObject* label );
    /** Adds a new field object to the section's field collection */
    void addField( MFieldObject* field );
    /** Adds a new special field object to the section's special field collection */
    void addSpecialField( MSpecialObject* special );
    /** Adds a new calculated field object to the section's calculated field collection */
    void addCalculatedField( MCalcObject* calc );
    /** Sets the height of the section */
    void setHeight( int h );
    /** Gets the height of the section */
    int getHeight();
    /** Sets the level of the section */
    void setLevel( int l );
    /** Gets the level of the section */
    int getLevel();
    /** Set the current page number - used by special fields */
    void setPageNumber( int page );
    /** Set the current date - used by special fields */
    void setReportDate( TQDate date );
    /** Sets the print frequency of the section */
    void setPrintFrequency( int printFrequency );
    /** Returns the print frequency of the section */
    int printFrequency();
    /** Returns the name of the bound field for the calculated field object at the given index */
    TQString getCalcFieldName( int idx );
    /** Returns the index of the calculated field object for the given bound field */
    int getCalcFieldIndex( TQString field );
    /** Sets the data for the specified calculated field */
    void setCalcFieldData( int idx, TQString data );
    /** Sets the data for the all calculated fields - list size must match number of calculated fields */
    void setCalcFieldData( TQPtrList<TQMemArray<double> >* values );
    /** Returns the number of calculated fields in the section */
    int getCalcFieldCount();
    /** Sets the field data */
    void setFieldData( TQString name, TQString data );
    /** Draws the section to the specified painter & x/y-offsets */
    virtual void draw( TQPainter* p, int xoffset, int yoffset );
    /** Frees all resources allocated by the report section */
    virtual void clear();

protected:
    /** Frees base resources allocated by the report section */
    void clearBase();
    /** Draws the section base objects to the specified painter & x/y offsets */
    void drawObjects( TQPainter* p, int xoffset, int yoffset );

private:
    /** Copies member data from one object to another.
      * Used by the copy constructor and assignment operator
      */
    void copy( const MReportSection* mReportSection );
};

}

#endif