~s-cecilio/lomse/master

« back to all changes in this revision

Viewing changes to src/graphic_model/lomse_gm_basic.cpp

  • Committer: cecilios
  • Date: 2010-10-10 13:35:19 UTC
  • Revision ID: git-v1:2b333198c3033525d15763b84eaf79dac9fdab80
Preparing to use CMake. Updating with new code and missing files. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//--------------------------------------------------------------------------------------
 
2
//  This file is part of the Lomse library.
 
3
//  Copyright (c) 2010 Lomse project
 
4
//
 
5
//  Lomse is free software; you can redistribute it and/or modify it under the
 
6
//  terms of the GNU General Public License as published by the Free Software Foundation,
 
7
//  either version 3 of the License, or (at your option) any later version.
 
8
//
 
9
//  Lomse is distributed in the hope that it will be useful, but WITHOUT ANY
 
10
//  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 
11
//  PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 
12
//
 
13
//  You should have received a copy of the GNU General Public License along
 
14
//  with Lomse; if not, see <http://www.gnu.org/licenses/>.
 
15
//  
 
16
//  For any comment, suggestion or feature request, please contact the manager of
 
17
//  the project at cecilios@users.sourceforge.net
 
18
//
 
19
//-------------------------------------------------------------------------------------
 
20
 
 
21
#include "lomse_gm_basic.h"
 
22
 
 
23
//#include <sstream>
 
24
//
 
25
//using namespace std;
 
26
 
 
27
namespace lomse
 
28
{
 
29
 
 
30
//-------------------------------------------------------------------------------------
 
31
// Graphic model implementation
 
32
//-------------------------------------------------------------------------------------
 
33
 
 
34
GraphicModel::GraphicModel()
 
35
{
 
36
    m_root = new GmoBoxDocument();
 
37
 
38
 
 
39
GraphicModel::~GraphicModel()
 
40
{
 
41
    if (m_root)
 
42
        delete m_root;
 
43
}
 
44
 
 
45
int GraphicModel::get_num_pages()
 
46
{
 
47
    return m_root->get_num_pages();
 
48
}
 
49
 
 
50
 
 
51
 
 
52
//-------------------------------------------------------------------------------------
 
53
// Graphic model objects (shapes and boxes) implementation
 
54
//-------------------------------------------------------------------------------------
 
55
 
 
56
GmoObj::GmoObj(GmoObj* owner)
 
57
    : m_pOwnerGmo(owner)
 
58
{
 
59
 
60
 
 
61
GmoObj::~GmoObj()
 
62
{
 
63
}
 
64
 
 
65
 
 
66
//-------------------------------------------------------------------------------------
 
67
// GmoBox
 
68
//-------------------------------------------------------------------------------------
 
69
 
 
70
GmoBox* GmoBox::get_child_box(int i)  //i = 0..n-1
 
71
{      
 
72
    if (i < get_num_children())
 
73
        return m_childBoxes[i]; 
 
74
    else
 
75
        return NULL;
 
76
}
 
77
 
 
78
 
 
79
//-------------------------------------------------------------------------------------
 
80
// GmoBoxDocPage
 
81
//-------------------------------------------------------------------------------------
 
82
 
 
83
GmoBoxDocPage::GmoBoxDocPage(GmoObj* owner)
 
84
    : GmoBox(owner)
 
85
{
 
86
}
 
87
 
 
88
 
 
89
//-------------------------------------------------------------------------------------
 
90
// GmoBoxDocument
 
91
//-------------------------------------------------------------------------------------
 
92
 
 
93
GmoBoxDocument::GmoBoxDocument() 
 
94
    : GmoBox(NULL) 
 
95
{
 
96
    add_new_page();
 
97
}
 
98
 
 
99
GmoBoxDocPage* GmoBoxDocument::add_new_page()
 
100
{
 
101
    GmoBoxDocPage* pPage = new GmoBoxDocPage(this);
 
102
    pPage->set_number(get_num_pages()+1);
 
103
    add_child_box(pPage);
 
104
    return pPage;
 
105
}
 
106
 
 
107
GmoBoxDocPage* GmoBoxDocument::get_page(int i) 
 
108
 
109
    return dynamic_cast<GmoBoxDocPage*>(get_child_box(i));
 
110
}
 
111
 
 
112
 
 
113
//-------------------------------------------------------------------------------------
 
114
// GmoBoxScore
 
115
//-------------------------------------------------------------------------------------
 
116
 
 
117
 
 
118
 
 
119
 
 
120
 
 
121
}  //namespace lomse