summaryrefslogtreecommitdiff
authorhrw <hrw>2005-07-19 18:18:32 (UTC)
committer hrw <hrw>2005-07-19 18:18:32 (UTC)
commitb21e6e799521ae1d08df8b220871d28b36f8eb70 (patch) (unidiff)
tree0af6177698a4cea83ea96d28d6587a87e790b42b
parent1bcae8d1a0964632f379cb1e5cd066fd2b736e0f (diff)
downloadopie-b21e6e799521ae1d08df8b220871d28b36f8eb70.zip
opie-b21e6e799521ae1d08df8b220871d28b36f8eb70.tar.gz
opie-b21e6e799521ae1d08df8b220871d28b36f8eb70.tar.bz2
removed hardcoded font size from graphs - now it's 1 smaller then default one
it would be nice to get _pCfg->getUseSmallFont here like it is done for lists
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/checkbook/graph.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/noncore/apps/checkbook/graph.cpp b/noncore/apps/checkbook/graph.cpp
index 72da738..279285a 100644
--- a/noncore/apps/checkbook/graph.cpp
+++ b/noncore/apps/checkbook/graph.cpp
@@ -84,34 +84,35 @@ void Graph::initGraph()
84 { 84 {
85 drawBarChart( width(), height(), data->maxValue(), data->minValue() ); 85 drawBarChart( width(), height(), data->maxValue(), data->minValue() );
86 } 86 }
87 break; 87 break;
88 case GraphInfo::PieChart : 88 case GraphInfo::PieChart :
89 { 89 {
90 drawPieChart( width(), height(), data->totalValue() ); 90 drawPieChart( width(), height(), data->totalValue() );
91 } 91 }
92 }; 92 };
93} 93}
94 94
95void Graph::drawBarChart( int width, int height, float max, float min ) 95void Graph::drawBarChart( int width, int height, float max, float min )
96{ 96{
97 QPainter p( &graph ); 97 QPainter p( &graph );
98 98
99 // Try to set the font size smaller for text 99 // Try to set the font size smaller for text
100 // it would be nice to get _pCfg->getUseSmallFont here
100 QFont f = font(); 101 QFont f = font();
101 f.setPointSize( 8 ); 102 f.setPointSize( f.pointSize()-1 );
102 p.setFont( f ); 103 p.setFont( f );
103 104
104 int x = 0; 105 int x = 0;
105 int i = 0; 106 int i = 0;
106 int n = data->numberDataPoints(); 107 int n = data->numberDataPoints();
107 QFontMetrics fm=fontMetrics(); 108 QFontMetrics fm=fontMetrics();
108 int fh = fm.height(); 109 int fh = fm.height();
109 int fw; 110 int fw;
110 111
111 QColor c( 0, 0, 255); 112 QColor c( 0, 0, 255);
112 p.setBrush( c ); 113 p.setBrush( c );
113 114
114 if ( min > 0 ) 115 if ( min > 0 )
115 min = 0.0; 116 min = 0.0;
116 117
117 int bw = ( width - width / 4 ) / n; 118 int bw = ( width - width / 4 ) / n;
@@ -120,34 +121,35 @@ void Graph::drawBarChart( int width, int height, float max, float min )
120 { 121 {
121 int bh = int( ( height - height / 4 - 1 ) * dp->value() / ( max - min ) ); 122 int bh = int( ( height - height / 4 - 1 ) * dp->value() / ( max - min ) );
122 p.drawRect( width / 8 + x, height - height / 8 - 1 - hoffset - bh, bw, bh ); 123 p.drawRect( width / 8 + x, height - height / 8 - 1 - hoffset - bh, bw, bh );
123 fw = fm.width( dp->label() ); 124 fw = fm.width( dp->label() );
124 p.drawText( width / 8 + x - fw / 2 + bw / 2, height - height / 8 - hoffset, fw, 125 p.drawText( width / 8 + x - fw / 2 + bw / 2, height - height / 8 - hoffset, fw,
125 fh + height / 8, AlignTop | AlignHCenter, dp->label() ); 126 fh + height / 8, AlignTop | AlignHCenter, dp->label() );
126 i++; 127 i++;
127 x += bw; 128 x += bw;
128 } 129 }
129} 130}
130 131
131void Graph::drawPieChart( int width, int height, float sum ) 132void Graph::drawPieChart( int width, int height, float sum )
132{ 133{
133 QPainter p( &graph ); 134 QPainter p( &graph );
134 135
135 // Try to set the font size smaller for text 136 // Try to set the font size smaller for text
137 // it would be nice to get _pCfg->getUseSmallFont here
136 QFont f = font(); 138 QFont f = font();
137 f.setPointSize( 8 ); 139 f.setPointSize( f.pointSize()-1 );
138 p.setFont( f ); 140 p.setFont( f );
139 141
140 int n = data->numberDataPoints(); 142 int n = data->numberDataPoints();
141 143
142 int apos = -90 * 16; 144 int apos = -90 * 16;
143 145
144 int xd = width - width / 5; 146 int xd = width - width / 5;
145 int yd = height - height / 5; 147 int yd = height - height / 5;
146 148
147 int i = 0; 149 int i = 0;
148 150
149 QColor c; 151 QColor c;
150 152
151 for (DataPointInfo *dp = data->firstDataPoint(); dp; dp = data->nextDataPoint() ) 153 for (DataPointInfo *dp = data->firstDataPoint(); dp; dp = data->nextDataPoint() )
152 { 154 {
153 c.setHsv( ( i *255) / n, 255, 255 ); 155 c.setHsv( ( i *255) / n, 255, 255 );