1 //
2 // This file is part of Gambit
3 // Copyright (c) 1994-2016, The Gambit Project (http://www.gambit-project.org)
4 //
5 // FILE: src/gui/style.h
6 // Class to store settings related to graphical interface styling
7 //
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 //
22 
23 #ifndef STYLE_H
24 #define STYLE_H
25 
26 #include "gambit/gambit.h"
27 #include "gambit/tinyxml.h"
28 
29 const int GBT_NODE_TOKEN_LINE = 0;
30 const int GBT_NODE_TOKEN_BOX = 1;
31 const int GBT_NODE_TOKEN_CIRCLE = 2;
32 const int GBT_NODE_TOKEN_DIAMOND = 3;
33 const int GBT_NODE_TOKEN_DOT = 4;
34 
35 const int GBT_BRANCH_STYLE_LINE = 0;
36 const int GBT_BRANCH_STYLE_FORKTINE = 1;
37 
38 const int GBT_BRANCH_LABEL_HORIZONTAL = 0;
39 const int GBT_BRANCH_LABEL_ROTATED = 1;
40 
41 const int GBT_INFOSET_JOIN_LINES = 0;
42 const int GBT_INFOSET_JOIN_CIRCLES = 1;
43 
44 const int GBT_INFOSET_CONNECT_NONE = 0;
45 const int GBT_INFOSET_CONNECT_SAMELEVEL = 1;
46 const int GBT_INFOSET_CONNECT_ALL = 2;
47 
48 const int GBT_NODE_LABEL_NOTHING = 0;
49 const int GBT_NODE_LABEL_LABEL = 1;
50 const int GBT_NODE_LABEL_PLAYER = 2;
51 const int GBT_NODE_LABEL_ISETLABEL = 3;
52 const int GBT_NODE_LABEL_ISETID = 4;
53 const int GBT_NODE_LABEL_REALIZPROB = 5;
54 const int GBT_NODE_LABEL_BELIEFPROB = 6;
55 const int GBT_NODE_LABEL_VALUE = 7;
56 
57 const int GBT_BRANCH_LABEL_NOTHING = 0;
58 const int GBT_BRANCH_LABEL_LABEL = 1;
59 const int GBT_BRANCH_LABEL_PROBS = 2;
60 const int GBT_BRANCH_LABEL_VALUE = 3;
61 
62 class wxFont;
63 
64 class gbtStyle {
65 private:
66   // Node styling
67   int m_nodeSize, m_terminalSpacing;
68   int m_chanceToken, m_playerToken, m_terminalToken;
69   bool m_rootReachable;
70 
71   // Branch styling
72   int m_branchLength, m_tineLength;
73   int m_branchStyle, m_branchLabels;
74 
75   // Information set styling
76   int m_infosetConnect, m_infosetJoin;
77 
78   // Legend styling
79   int m_nodeAboveLabel, m_nodeBelowLabel;
80   int m_branchAboveLabel, m_branchBelowLabel;
81 
82   // Fonts for legends
83   wxFont m_font;
84 
85   // Colors for nodes
86   wxColour m_chanceColor, m_terminalColor;
87   mutable Gambit::Array<wxColour> m_playerColors;
88 
89   // Decimal places to display
90   int m_numDecimals;
91 
92 public:
93   // Lifecycle
94   gbtStyle(void);
95 
96   // Node styling
NodeSize(void)97   int NodeSize(void) const { return m_nodeSize; }
SetNodeSize(int p_nodeSize)98   void SetNodeSize(int p_nodeSize) { m_nodeSize = p_nodeSize; }
99 
TerminalSpacing(void)100   int TerminalSpacing(void) const { return m_terminalSpacing; }
SetTerminalSpacing(int p_spacing)101   void SetTerminalSpacing(int p_spacing) { m_terminalSpacing = p_spacing; }
102 
ChanceToken(void)103   int ChanceToken(void) const { return m_chanceToken; }
SetChanceToken(int p_token)104   void SetChanceToken(int p_token) { m_chanceToken = p_token; }
105 
PlayerToken(void)106   int PlayerToken(void) const { return m_playerToken; }
SetPlayerToken(int p_token)107   void SetPlayerToken(int p_token) { m_playerToken = p_token; }
108 
TerminalToken(void)109   int TerminalToken(void) const { return m_terminalToken; }
SetTerminalToken(int p_token)110   void SetTerminalToken(int p_token) { m_terminalToken = p_token; }
111 
RootReachable(void)112   bool RootReachable(void) const { return m_rootReachable; }
SetRootReachable(bool p_reachable)113   void SetRootReachable(bool p_reachable) { m_rootReachable = p_reachable; }
114 
115 
116   // Branch styling
BranchLength(void)117   int BranchLength(void) const { return m_branchLength; }
SetBranchLength(int p_length)118   void SetBranchLength(int p_length) { m_branchLength = p_length; }
119 
TineLength(void)120   int TineLength(void) const { return m_tineLength; }
SetTineLength(int p_length)121   void SetTineLength(int p_length) { m_tineLength = p_length; }
122 
BranchStyle(void)123   int BranchStyle(void) const { return m_branchStyle; }
SetBranchStyle(int p_style)124   void SetBranchStyle(int p_style) { m_branchStyle = p_style; }
125 
BranchLabels(void)126   int BranchLabels(void) const { return m_branchLabels; }
SetBranchLabels(int p_labels)127   void SetBranchLabels(int p_labels) { m_branchLabels = p_labels; }
128 
129 
130   // Information set styling
InfosetConnect(void)131   int InfosetConnect(void) const { return m_infosetConnect; }
SetInfosetConnect(int p_connect)132   void SetInfosetConnect(int p_connect) { m_infosetConnect = p_connect; }
133 
InfosetJoin(void)134   int InfosetJoin(void) const { return m_infosetJoin; }
SetInfosetJoin(int p_join)135   void SetInfosetJoin(int p_join) { m_infosetJoin = p_join; }
136 
137 
138   // Legends
NodeAboveLabel(void)139   int NodeAboveLabel(void) const { return m_nodeAboveLabel; }
SetNodeAboveLabel(int p_label)140   void SetNodeAboveLabel(int p_label) { m_nodeAboveLabel = p_label; }
141 
NodeBelowLabel(void)142   int NodeBelowLabel(void) const { return m_nodeBelowLabel; }
SetNodeBelowLabel(int p_label)143   void SetNodeBelowLabel(int p_label) { m_nodeBelowLabel = p_label; }
144 
BranchAboveLabel(void)145   int BranchAboveLabel(void) const { return m_branchAboveLabel; }
SetBranchAboveLabel(int p_label)146   void SetBranchAboveLabel(int p_label) { m_branchAboveLabel = p_label; }
147 
BranchBelowLabel(void)148   int BranchBelowLabel(void) const { return m_branchBelowLabel; }
SetBranchBelowLabel(int p_label)149   void SetBranchBelowLabel(int p_label) { m_branchBelowLabel = p_label; }
150 
151   // Fonts
GetFont(void)152   const wxFont &GetFont(void) const { return m_font; }
SetFont(const wxFont & p_font)153   void SetFont(const wxFont &p_font) { m_font = p_font; }
154 
155   // Colors
ChanceColor(void)156   const wxColour &ChanceColor(void) const { return m_chanceColor; }
SetChanceColor(const wxColour & p_color)157   void SetChanceColor(const wxColour &p_color) { m_chanceColor = p_color; }
158 
TerminalColor(void)159   const wxColour &TerminalColor(void) const { return m_terminalColor; }
SetTerminalColor(const wxColour & p_color)160   void SetTerminalColor(const wxColour &p_color) { m_terminalColor = p_color; }
161 
162   const wxColour &GetPlayerColor(int pl) const;
SetPlayerColor(int pl,const wxColour & p_color)163   void SetPlayerColor(int pl, const wxColour &p_color)
164     { m_playerColors[pl] = p_color; }
165 
166   // Decimals
NumDecimals(void)167   int NumDecimals(void) const { return m_numDecimals; }
SetNumDecimals(int p_decimals)168   void SetNumDecimals(int p_decimals) { m_numDecimals = p_decimals; }
169 
170   // Reset to the "factory" defaults
171   void SetDefaults(void);
172 
173   /// @name Reading and writing XML
174   //@{
175   /// Get the color settings as an XML entry
176   std::string GetColorXML(void) const;
177   /// Set the color settings from an XML entry
178   void SetColorXML(TiXmlNode *p_node);
179 
180   /// Get the font settings as an XML entry
181   std::string GetFontXML(void) const;
182   /// Set the font settings from an XML entry
183   void SetFontXML(TiXmlNode *p_node);
184 
185   /// Get the layout settings as an XML entry
186   std::string GetLayoutXML(void) const;
187   /// Set the layout settings from an XML entry
188   void SetLayoutXML(TiXmlNode *p_node);
189 
190   /// Get the label settings as an XML entry
191   std::string GetLabelXML(void) const;
192   /// Set the label settings from an XML entry
193   void SetLabelXML(TiXmlNode *p_node);
194   //@}
195 };
196 
197 #endif  // STYLE_H
198