Money Manager EX
An easy to use, money management application built with wxWidgets
htmlbuilder.h
Go to the documentation of this file.
1 /*******************************************************
2  Copyright (C) 2006 Madhan Kanagavel
3  Copyright (C) 2012 - 2021 Nikolay Akimov
4  Copyright (C) 2021 - 2022 Mark Whalley (mark@ipx.co.uk)
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  ********************************************************/
20 
21 #ifndef MM_EX_HTMLBUILDER_H_
22 #define MM_EX_HTMLBUILDER_H_
23 
24 #include "defs.h"
25 #include <vector>
26 #include "model/Model_Currency.h"
27 #include "html_template.h"
28 #include "util.h"
29 
31 {
32  wxString name;
33  wxString type;
34  std::vector<double> values;
35 };
36 
37 struct GraphData
38 {
39  wxString title;
40  enum GraphType { BAR = 0, LINE, LINE_DATETIME, PIE, DONUT, RADAR, BARLINE, STACKEDBARLINE, STACKEDAREA } type;
41  //Keep type aligned in FilterTransDialog CHART_OPTIONS
42  std::vector<wxString> labels;
43  std::vector<GraphSeries> series;
44  std::vector<wxColour> colors;
45 };
46 
48 {
49 public:
50  mmHTMLBuilder();
52 
53  void DisplayDateHeading(const wxDateTime& startDate, const wxDateTime& endDate, bool withDateRange = true, bool withNoEndDate = false);
54  void DisplayFooter(const wxString& footer);
56  void init(bool simple = false, const wxString& extra_style = "");
57 
59  void clear()
60  {
61  html_.clear();
62  }
63 
65  void addReportHeader(const wxString& name, int startDay = 1, bool futureIgnored = false);
66  void addHeader(int level, const wxString& header);
67  void showUserName();
68  void addReportCurrency();
69  void addDateNow();
70  void addOffsetIndication(int startDay);
71  void addFutureIgnoredIndication(bool ignore);
72 
74  void startTable();
75  void startSortTable();
76  void startThead();
77  void startTbody();
78  void startTfoot();
79 
81  void addTotalRow(const wxString& caption, int cols, double value);
82 
84  void addTotalRow(const wxString& caption, int cols, const std::vector<wxString>& data);
85  void addCurrencyTotalRow(const wxString& caption, int cols, const std::vector<double>& data);
86  void addMoneyTotalRow(const wxString& caption, int cols, const std::vector<double>& data);
87 
89  //void addTableHeaderCell(const wxString& value, bool numeric = false, bool sortable = true, int cols = 1, bool center = false);
90  void addTableHeaderCell(const wxString& value, const wxString& css_class = "", int cols = 1);
91 
92  void addCurrencyCell(double amount, const Model_Currency::Data *currency = Model_Currency::instance().GetBaseCurrency(), int precision = -1, bool isVoid = false);
93  void addMoneyCell(double amount, int precision = -1);
94  void addTableCellMonth(int month, int year = 0);
95  void addColorMarker(const wxString& color, bool center = false);
96  const wxString getColor(int i);
97  const wxString getFormattedLink(const wxString& color, const wxString& href_value, const wxString& a_value);
98  const wxString getRandomColor(bool positive);
99 
101  void addTableCellDate(const wxString& iso_date);
102  void addTableCell(const wxString& value, bool numeric = false, bool center = false);
103  void addEmptyTableCell(const int number = 1);
104 
106  void addTableCellLink(const wxString& href, const wxString& value, bool numeric = false, bool center = false);
107 
108  void end(bool simple=false);
109  void endTable();
110  void endThead();
111  void endTbody();
112  void endTfoot();
113  void addDivContainer(const wxString& style = "container");
114  void addDivRow();
115  void addDivCol17_67();
116  void addDivCol25_50();
117  void addDivCol8_84();
118  void endDiv();
119  void addEmptyTableRow(int cols);
120  void startTableRow();
121  void startTableRow(const wxString& classname);
122  void startTableRowColor(const wxString& color);
123  void startAltTableRow();
124  void startTotalTableRow();
125  //void startTableRow(const wxString& custom_color);
126  void endTableRow();
127  void startSpan(const wxString& val, const wxString& style);
128  void endSpan();
129 
131  void addText(const wxString& text);
132 
134  void addLineBreak();
136  void addHorizontalLine(int size = 0);
137 
139  void startTableCell(const wxString& width = "");
140  void endTableCell();
141 
142  const wxString getHTMLText() const;
143 
144  void addTableRow(const wxString& label, double data);
145  void addTableRowBold(const wxString& label, double data);
146 
147  void addChart(const GraphData& data);
148 
149 private:
150  wxString html_;
151  struct today_
152  {
153  wxDateTime date;
154  wxString date_str;
155  wxString todays_date;
156  } today_;
157 };
158 
159 
160 #endif
std::vector< wxString > labels
Definition: htmlbuilder.h:42
Definition: htmlbuilder.h:47
std::vector< GraphSeries > series
Definition: htmlbuilder.h:43
Data is a single record in the database table.
Definition: DB_Table_Currencyformats_V1.h:415
std::vector< double > values
Definition: htmlbuilder.h:34
~mmHTMLBuilder()
Definition: htmlbuilder.h:51
GraphType
Definition: htmlbuilder.h:40
wxString title
Definition: htmlbuilder.h:39
std::vector< wxColour > colors
Definition: htmlbuilder.h:44
Definition: htmlbuilder.h:30
void clear()
Clears the current HTML document.
Definition: htmlbuilder.h:59
Definition: htmlbuilder.h:37
static Model_Currency & instance()
Return the static instance address for Model_Currency table Note: Assigning the address to a local va...
Definition: Model_Currency.cpp:70
Definition: htmlbuilder.h:40
wxString name
Definition: htmlbuilder.h:32
wxString type
Definition: htmlbuilder.h:33