summaryrefslogtreecommitdiff
path: root/include/worksheet_viewitem.h
blob: 149f8045309bb02d23c4364b6a5bbd5f49481f09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/*
 * This program source code file is part of KICAD, a free EDA CAD application.
 *
 * Copyright (C) 2013 CERN
 * @author Maciej Suminski <maciej.suminski@cern.ch>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, you may find one here:
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * or you may search the http://www.gnu.org website for the version 2 license,
 * or you may write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 */

/**
 * @file worksheet_viewitem.h
 * @brief Class that handles properties and drawing of worksheet layout.
 */

#ifndef WORKSHEET_VIEWITEM_H
#define WORKSHEET_VIEWITEM_H

#include <base_struct.h>

class BOARD;
class PAGE_INFO;
class TITLE_BLOCK;
class WS_DRAW_ITEM_LINE;
class WS_DRAW_ITEM_RECT;
class WS_DRAW_ITEM_POLYGON;
class WS_DRAW_ITEM_TEXT;

namespace KIGFX
{
class GAL;

class WORKSHEET_VIEWITEM : public EDA_ITEM
{
public:
    WORKSHEET_VIEWITEM( const PAGE_INFO* aPageInfo, const TITLE_BLOCK* aTitleBlock );

    /**
     * Function SetFileName()
     * Sets the file name displayed in the title block.
     *
     * @param aFileName is the new file name.
     */
    void SetFileName( const std::string& aFileName )
    {
        m_fileName = aFileName;
        ViewUpdate( GEOMETRY );
    }

    /**
     * Function SetSheetName()
     * Sets the sheet name displayed in the title block.
     *
     * @param aSheetName is the new sheet name.
     */
    void SetSheetName( const std::string& aSheetName )
    {
        m_sheetName = aSheetName;
        ViewUpdate( GEOMETRY );
    }

    /**
     * Function SetPageInfo()
     * Changes the PAGE_INFO object used to draw the worksheet.
     *
     * @param aPageInfo is the new PAGE_INFO object.
     */
    void SetPageInfo( const PAGE_INFO* aPageInfo );

    /**
     * Function SetTitleBlock()
     * Changes the TITLE_BLOCK object used to draw the worksheet.
     *
     * @param aTitleBlock is the new TITLE_BLOCK object.
     */
    void SetTitleBlock( const TITLE_BLOCK* aTitleBlock );

    /**
     * Function SetSheetNumber()
     * Changes the sheet number displayed in the title block.
     *
     * @param aSheetNumber is the new sheet number.
     */
    void SetSheetNumber( int aSheetNumber )
    {
        m_sheetNumber = aSheetNumber;
        ViewUpdate( GEOMETRY );

    }

    /**
     * Function SetSheetCount()
     * Changes the sheets count number displayed in the title block.
     *
     * @param aSheetCount is the new sheets count number.
     */
    void SetSheetCount( int aSheetCount )
    {
        m_sheetCount = aSheetCount;
        ViewUpdate( GEOMETRY );
    }

    /// @copydoc VIEW_ITEM::ViewBBox()
    const BOX2I ViewBBox() const;

    /// @copydoc VIEW_ITEM::ViewDraw()
    void ViewDraw( int aLayer, GAL* aGal ) const;

    /// @copydoc VIEW_ITEM::ViewGetLayers()
    void ViewGetLayers( int aLayers[], int& aCount ) const;

#if defined(DEBUG)
    /// @copydoc EDA_ITEM::Show()
    void Show( int x, std::ostream& st ) const
    {
    }
#endif

    /** Get class name
     * @return  string "WORKSHEET_VIEWITEM"
     */
    virtual wxString GetClass() const
    {
        return wxT( "WORKSHEET_VIEWITEM" );
    }

protected:
    /// File name displayed in the title block
    std::string m_fileName;

    /// Sheet name displayed in the title block
    std::string m_sheetName;

    /// Title block that contains properties of the title block displayed in the worksheet.
    const TITLE_BLOCK* m_titleBlock;

    /// Worksheet page information.
    const PAGE_INFO* m_pageInfo;

    /// Sheet number displayed in the title block.
    int m_sheetNumber;

    /// Sheets count number displayed in the title block.
    int m_sheetCount;

    // Functions for drawing items that makes a worksheet
    void draw( const WS_DRAW_ITEM_LINE* aItem, GAL* aGal ) const;
    void draw( const WS_DRAW_ITEM_RECT* aItem, GAL* aGal ) const;
    void draw( const WS_DRAW_ITEM_POLYGON* aItem, GAL* aGal ) const;
    void draw( const WS_DRAW_ITEM_TEXT* aItem, GAL* aGal ) const;

    /// Draws a border that determines the page size.
    void drawBorder( GAL* aGal ) const;
};
}

#endif /* WORKSHEET_VIEWITEM_H */