~ubuntu-branches/ubuntu/hardy/codeblocks/hardy-backports

« back to all changes in this revision

Viewing changes to src/plugins/contrib/wxSmithContribItems/wxchart/wxchart-1.0/src/xaxis.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michael Casadevall
  • Date: 2008-07-17 04:39:23 UTC
  • Revision ID: james.westby@ubuntu.com-20080717043923-gmsy5cwkdjswghkm
Tags: upstream-8.02
ImportĀ upstreamĀ versionĀ 8.02

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/////////////////////////////////////////////////////////////////////////////
 
2
// Name:        xaxis.cpp
 
3
// Purpose:     wxChart
 
4
// Author:      Paolo Gava
 
5
// Modified by:
 
6
// Created:
 
7
// Copyright:   (C) 2006, Paolo Gava
 
8
// RCS-ID:      $Id: xaxis.cpp 4016 2007-05-30 23:08:39Z byo $
 
9
// Licence:     wxWindows licence
 
10
/////////////////////////////////////////////////////////////////////////////
 
11
 
 
12
//----------------------------------------------------------------------------
 
13
// Headers
 
14
//----------------------------------------------------------------------------
 
15
 
 
16
// c++
 
17
#include <cmath>
 
18
 
 
19
// wx
 
20
 
 
21
// For compilers that support precompilation, includes "wx.h".
 
22
#include <wx/wxprec.h>
 
23
 
 
24
#ifdef __BORLANDC__
 
25
#pragma hdrstop
 
26
#endif
 
27
 
 
28
#ifndef WX_PRECOMP
 
29
#include <wx/wx.h>
 
30
#endif
 
31
 
 
32
#include "wx/xaxis.h"
 
33
 
 
34
//+++-S-cf-------------------------------------------------------------------
 
35
//      NAME:           Draw()
 
36
//      DESC:           Draw xaxis
 
37
//      PARAMETERS:     CHART_HPAINT hp,
 
38
//                              CHART_HRECT hr
 
39
//      RETURN:         None
 
40
//----------------------------------------------------------------------E-+++
 
41
void wxXAxis::Draw(
 
42
        CHART_HPAINT hp,
 
43
        CHART_HRECT hr
 
44
)
 
45
{
 
46
 
 
47
        if ( GetVirtualMax() > 0 )
 
48
        {
 
49
                wxFont font(8, wxROMAN, wxNORMAL, wxNORMAL);
 
50
        hp->SetFont(font);
 
51
        hp->SetPen( *wxBLACK_PEN );
 
52
 
 
53
        int iNodes = static_cast<int>(ceil( GetVirtualMax() ));
 
54
                ChartSizes sizes = GetSizes();
 
55
 
 
56
                double x;
 
57
 
 
58
                //-------------------------------------------------------------------
 
59
                // If hr->x != 0 means we are drawing the axis on file. So the
 
60
                // following condition prevent from drawing only part of the axis ie
 
61
                // ignor any scroll position
 
62
                // TODO: any better idea?!
 
63
                //-------------------------------------------------------------------
 
64
                if ( hr->x == 0 )
 
65
                {
 
66
                        hr->xscroll *= sizes.scroll;
 
67
                        x = 0 - hr->xscroll;
 
68
                }
 
69
                else
 
70
                        x = 0;
 
71
 
 
72
                for ( int iNode = 0; iNode <= iNodes; ++ iNode )
 
73
                {
 
74
                        if ( x >= 0 )
 
75
                        {
 
76
                                wxString label;
 
77
 
 
78
                hp->DrawLine( static_cast<int>(ceil(x)) + hr->x, 5 + hr->y,
 
79
                              static_cast<int>(ceil(x)) + hr->x, 15 + hr->y );
 
80
 
 
81
                label.Printf( wxT("%d"), iNode );
 
82
                hp->DrawText( label, static_cast<int>(ceil(x)) +
 
83
                              hr->x, 20 + hr->y );
 
84
                        }
 
85
                        x +=  GetZoom() * ( sizes.wbar * sizes.nbar +
 
86
                                                                sizes.wbar3d * sizes.nbar3d +
 
87
                                                                sizes.gap );
 
88
                }
 
89
 
 
90
        hp->DrawLine( hr->x, hr->y + 1, hr->x + static_cast<int>(ceil(x)),
 
91
                      hr->y + 1 );
 
92
 
 
93
        }
 
94
}