~ubuntu-branches/ubuntu/raring/codeblocks/raring-proposed

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Cosme Domínguez Díaz
  • Date: 2010-08-09 04:38:38 UTC
  • mfrom: (1.1.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20100809043838-a59ygguym4eg0jgw
Tags: 10.05-0ubuntu1
* New upstream release. Closes (LP: #322350)
 - Switch to dpkg-source 3.0 (quilt) format
 - Remove unneeded README.source
 - Add debian/get-source-orig script that removes all
   Windows prebuilt binaries
* Bump Standards-Version to 3.9.1
 - Stop shipping *.la files
* debian/control
 - Add cdbs package as Build-Depend
 - Add libbz2-dev and zlib1g-dev packages as
   Build-Depends (needed by libhelp_plugin.so)
 - Remove dpatch package of Build-Depends
 - Add codeblocks-contrib-debug package
 - Split architecture-independent files of codeblocks
   package in codeblocks-common package
* debian/rules
 - Switch to CDBS rules system
 - Add parallel build support
 - Add a call to debian/get-source-orig script
 - Use lzma compression (saves 23,5 MB of free space)
* debian/patches
 - Refresh 01_codeblocks_plugin_path
 - Add 02_no_Makefiles_in_debian_dir to remove any link
   in codeblocks build system to deleted Makefiles of debian directory
 - Drop 02_ftbfs_gcc44 and 03_ftbfs_glib221 (merged in upstream)
* debian/watch
 - Update to use the new host (berlios.de)

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
// Modified by:
6
6
// Created:
7
7
// Copyright:   (C) 2006, Paolo Gava
8
 
// RCS-ID:      $Id: legend.cpp 4016 2007-05-30 23:08:39Z byo $
 
8
// RCS-ID:      $Id: legend.cpp 5961 2009-12-08 06:24:32Z mortenmacfly $
9
9
// Licence:     wxWindows licence
10
10
/////////////////////////////////////////////////////////////////////////////
11
11
 
14
14
//----------------------------------------------------------------------------
15
15
 
16
16
// wx
 
17
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
 
18
#pragma implementation "legend.h"
 
19
#endif
17
20
 
18
21
// For compilers that support precompilation, includes "wx.h".
19
22
#include <wx/wxprec.h>
29
32
#include "wx/chartcolors.h"
30
33
#include "wx/legend.h"
31
34
 
 
35
//#if !wxUSE_GLCANVAS
 
36
//    #error "OpenGL required: set wxUSE_GLCANVAS to 1 and rebuild the library"
 
37
//#endif
 
38
 
32
39
//----------------------------------------------------------------------------
33
40
// Define Array/List of Points
34
41
//----------------------------------------------------------------------------
38
45
 
39
46
//+++-S-cf-------------------------------------------------------------------
40
47
//  NAME:       dtor
41
 
//  DESC:
 
48
//  DESC:       
42
49
//  PARAMETERS: None
43
50
//  RETURN:     None
44
51
//----------------------------------------------------------------------E-+++
45
 
wxLegend::wxLegend()
 
52
wxLegend::wxLegend() 
46
53
    : m_Page(0)
47
54
{
48
55
}
49
56
 
50
57
//+++-S-cf-------------------------------------------------------------------
51
58
//  NAME:       dtor
52
 
//  DESC:
 
59
//  DESC:       
53
60
//  PARAMETERS: None
54
61
//  RETURN:     None
55
62
//----------------------------------------------------------------------E-+++
56
 
wxLegend::~wxLegend()
 
63
wxLegend::~wxLegend() 
57
64
{
58
65
    m_lDescs.Clear();
59
66
}
61
68
//+++-S-cf-------------------------------------------------------------------
62
69
//      NAME:           Add()
63
70
//      DESC:           List descriptos utilities
64
 
//      PARAMETERS:     const wxString &lbl,
 
71
//      PARAMETERS:     const wxString &lbl, 
65
72
//                              const ChartColor &col
66
73
//      RETURN:         None
67
74
//----------------------------------------------------------------------E-+++
68
75
void wxLegend::Add(
69
 
        const wxString &lbl,
 
76
        const wxString &lbl, 
70
77
        const ChartColor &col
71
 
)
72
 
{
73
 
        m_lDescs.Add( DescLegend(lbl, col) );
 
78
 
79
 
80
        m_lDescs.Add( DescLegend(lbl, col) ); 
74
81
}
75
82
 
76
83
//+++-S-cf-------------------------------------------------------------------
79
86
//      PARAMETERS:     None
80
87
//      RETURN:         None
81
88
//----------------------------------------------------------------------E-+++
82
 
void wxLegend::Clear()
83
 
{
84
 
        m_lDescs.Clear();
 
89
void wxLegend::Clear() 
 
90
 
91
        m_lDescs.Clear(); 
85
92
}
86
93
 
87
94
//+++-S-cf-------------------------------------------------------------------
92
99
//----------------------------------------------------------------------E-+++
93
100
int wxLegend::GetCount() const
94
101
{
95
 
        return ( m_lDescs.GetCount() );
 
102
        return ( m_lDescs.GetCount() ); 
96
103
}
97
104
 
98
105
//+++-S-cf-------------------------------------------------------------------
106
113
) const
107
114
{
108
115
        ChartColor colRes = wxCHART_NOCOLOR;
109
 
 
 
116
        
110
117
    int iMax = GetCount();
111
118
        if ( iMax > n )
112
119
        {
127
134
) const
128
135
{
129
136
    wxString lblRes = wxEmptyString;
130
 
 
 
137
        
131
138
        int iMax = GetCount();
132
139
        if ( iMax > n )
133
140
        {
134
141
        lblRes = m_lDescs.Item( n ).m_lbl;
135
 
 
 
142
           
136
143
        }
137
144
 
138
145
        return ( lblRes );
141
148
//+++-S-cf-------------------------------------------------------------------
142
149
//  NAME:       Draw()
143
150
//  DESC:       Draw legend
144
 
//  PARAMETERS: CHART_HPAINT hp,
 
151
//  PARAMETERS: CHART_HPAINT hp, 
145
152
//              CHART_HRECT hr
146
153
//  RETURN:     None
147
154
//----------------------------------------------------------------------E-+++
148
155
void wxLegend::Draw(
149
 
    CHART_HPAINT hp,
 
156
    CHART_HPAINT hp, 
150
157
    CHART_HRECT hr
151
158
)
152
 
{
 
159
{    
153
160
    int iPages = NumPages();
154
161
    int iLines = iPages > 0 ? ROWS_PAGE : GetCount();
155
162
    wxCoord h;
167
174
    {
168
175
        hp->SetBrush( *wxGREY_BRUSH );
169
176
        hp->SetPen( *wxBLACK_PEN );
170
 
 
 
177
        
171
178
        DrawArrow( hp, x+hr->w/2, y, 8, ARROW_UP, false );
172
179
        hp->DrawLine( x+15, y+10, x+hr->w-15, y+10);
173
180
        DrawArrow( hp, x+hr->w/2, y + 20, 8, ARROW_DOWN, false );
206
213
    int iDatas = GetCount();
207
214
    int iPages = NumPages();
208
215
 
209
 
    if ( iPages * ROWS_PAGE != iDatas )
 
216
    if ( iPages * ROWS_PAGE != iDatas ) 
210
217
        iPages += 1;
211
218
 
212
219
    if ( m_Page + 1 < iPages )
229
236
//+++-S-cf-------------------------------------------------------------------
230
237
//  NAME:       IsInArrowUp()
231
238
//  DESC:       Mouse utilities
232
 
//  PARAMETERS: int x,
 
239
//  PARAMETERS: int x, 
233
240
//              int y
234
241
//  RETURN:     None
235
242
//----------------------------------------------------------------------E-+++
236
243
bool wxLegend::IsInArrowUp(
237
 
    int x,
 
244
    int x, 
238
245
    int y
239
246
)
240
247
{
249
256
//+++-S-cf-------------------------------------------------------------------
250
257
//  NAME:       IsInArrowUp()
251
258
//  DESC:       Mouse utilities
252
 
//  PARAMETERS: int x,
 
259
//  PARAMETERS: int x, 
253
260
//              int y
254
261
//  RETURN:     None
255
262
//----------------------------------------------------------------------E-+++
256
263
bool wxLegend::IsInArrowDown(
257
 
    int x,
 
264
    int x, 
258
265
    int y
259
266
)
260
267
{
269
276
//+++-S-cf-------------------------------------------------------------------
270
277
//  NAME:       DrawArrow()
271
278
//  DESC:       Draw arrow
272
 
//  PARAMETERS: CHART_HPAINT hp,
 
279
//  PARAMETERS: CHART_HPAINT hp, 
273
280
//              int pos,
274
281
//              bool over
275
282
//  RETURN:     None
276
283
//----------------------------------------------------------------------E-+++
277
284
void wxLegend::DrawArrow(
278
 
    CHART_HPAINT hp,
 
285
    CHART_HPAINT hp, 
279
286
    int pos,
280
287
    bool over
281
288
)
282
 
{
 
289
{    
283
290
    //-----------------------------------------------------------------------
284
291
    // Get actual configuration
285
292
    //-----------------------------------------------------------------------
286
293
    wxBrush oldBrush = hp->GetBrush();
287
294
    wxPen oldPen = hp->GetPen();
288
 
 
 
295
    
289
296
    //-----------------------------------------------------------------------
290
297
    // if mouse over use different colours
291
298
    //-----------------------------------------------------------------------
292
 
 
 
299
    
293
300
    if (over)
294
 
    {
 
301
    {        
295
302
        hp->SetBrush( *wxBLACK_BRUSH );
296
303
        hp->SetPen( *wxBLACK_PEN );
297
304
    }
300
307
        hp->SetBrush( *wxGREY_BRUSH );
301
308
        hp->SetPen( *wxBLACK_PEN );
302
309
    }
303
 
 
 
310
    
304
311
    if ( pos == ARROW_DOWN )
305
312
    {
306
313
        //-------------------------------------------------------------------
321
328
            DrawArrow(hp, m_ArrowUp.m_x, m_ArrowUp.m_y, 8, pos, over);
322
329
        }
323
330
    }
324
 
 
 
331
        
325
332
    //-----------------------------------------------------------------------
326
333
    // Set old colours
327
334
    //-----------------------------------------------------------------------
328
335
    hp->SetBrush( oldBrush );
329
336
    hp->SetPen( oldPen );
330
 
 
 
337
    
331
338
}
332
339
 
333
340
//+++-S-cf-------------------------------------------------------------------
334
341
//  NAME:       DrawArrow()
335
342
//  DESC:       Draw arrow
336
 
//  PARAMETERS: CHART_HPAINT hp,
337
 
//              int x,
 
343
//  PARAMETERS: CHART_HPAINT hp, 
 
344
//              int x, 
338
345
//              int y,
339
346
//              int size,
340
347
//              int pos,
342
349
//  RETURN:     None
343
350
//----------------------------------------------------------------------E-+++
344
351
void wxLegend::DrawArrow(
345
 
    CHART_HPAINT hp,
346
 
    int x,
 
352
    CHART_HPAINT hp, 
 
353
    int x, 
347
354
    int y,
348
355
    int size,
349
356
    int pos,
350
357
    bool over
351
358
)
352
 
{
 
359
{    
353
360
    if ( pos == ARROW_DOWN )
354
361
        size *= (-1);
355
362
 
356
 
    wxPoint points[] = {
357
 
        wxPoint( x, y ),
358
 
        wxPoint( x - size, y + size ),
 
363
    wxPoint points[] = { 
 
364
        wxPoint( x, y ), 
 
365
        wxPoint( x - size, y + size ), 
359
366
        wxPoint( x + size, y + size) };
360
367
    hp->DrawPolygon( 3, points );
361
368
 
364
371
        m_ArrowUp.m_x = x;
365
372
        m_ArrowUp.m_y = y;
366
373
        m_ArrowUp.m_d = y + size/2;
367
 
        m_ArrowUp.m_sel = over;
 
374
        m_ArrowUp.m_sel = over;           
368
375
    }
369
376
    else
370
377
    {
371
378
        m_ArrowDown.m_x = x;
372
379
        m_ArrowDown.m_y = y;
373
380
        m_ArrowDown.m_d = y + size/2;;
374
 
        m_ArrowDown.m_sel = over;
 
381
        m_ArrowDown.m_sel = over;           
375
382
    }
376
383
}
377
384
 
378
385
//+++-S-cf-------------------------------------------------------------------
379
386
//  NAME:       WriteLabel()
380
 
//  DESC:       Write ROWS_PAGE labels starting from page
381
 
//  PARAMETERS: CHART_HPAINT hp,
382
 
//              int x,
383
 
//              int y,
 
387
//  DESC:       Write ROWS_PAGE labels starting from page 
 
388
//  PARAMETERS: CHART_HPAINT hp, 
 
389
//              int x, 
 
390
//              int y, 
384
391
//              int page
385
392
//  RETURN:     None
386
393
//----------------------------------------------------------------------E-+++
387
394
void wxLegend::WriteLabel(
388
 
    CHART_HPAINT hp,
389
 
    int x,
390
 
    int y,
 
395
    CHART_HPAINT hp, 
 
396
    int x, 
 
397
    int y, 
391
398
    int page
392
399
)
393
 
{
 
400
{    
394
401
    int iDatas = GetCount();
395
402
 
396
403
    wxFont font(8, wxROMAN, wxNORMAL, wxNORMAL);
398
405
    hp->SetPen( *wxBLACK_PEN );
399
406
 
400
407
    wxString label;
401
 
 
402
 
    for ( int iData = page * ROWS_PAGE;
403
 
          iData < iDatas && iData < (page+1) * ROWS_PAGE;
 
408
    
 
409
    for ( int iData = page * ROWS_PAGE; 
 
410
          iData < iDatas && iData < (page+1) * ROWS_PAGE; 
404
411
          ++ iData )
405
412
    {
406
413
        hp->SetBrush( wxBrush(GetColor(iData), wxSOLID) );
407
414
        hp->SetPen( *wxTRANSPARENT_PEN );
408
415
        hp->DrawRectangle( x, y+2, 10, 10 );
409
 
 
 
416
        
410
417
        hp->SetPen( *wxBLACK_PEN );
411
418
        label = GetLabel( iData ).c_str();
412
419
        label.Truncate( 5 );
413
420
        hp->DrawText( label, x + 15, y );
414
 
 
 
421
        
415
422
        y += ROW_SIZE;
416
423
    }
417
424
}