~s-cecilio/lomse/master

« back to all changes in this revision

Viewing changes to include/lomse_gm_basic.h

  • 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
#ifndef __LOMSE_GM_BASIC_H__
 
22
#define __LOMSE_GM_BASIC_H__
 
23
 
 
24
#include <vector>
 
25
//#include <iostream>
 
26
//#include "lomse_observable.h"
 
27
 
 
28
using namespace std;
 
29
 
 
30
namespace lomse
 
31
{
 
32
 
 
33
//forward declarations
 
34
class GmoObj;
 
35
class GmoBox;
 
36
class GmoBoxDocument;
 
37
class GmoBoxDocPage;
 
38
class GmoBoxScore;
 
39
class GmoShape;
 
40
 
 
41
 
 
42
//the graphic model
 
43
//------------------------------------------------------------------------------
 
44
class GraphicModel
 
45
{
 
46
protected:
 
47
    GmoBoxDocument* m_root;
 
48
 
 
49
public:
 
50
    GraphicModel();
 
51
    ~GraphicModel();
 
52
 
 
53
    inline GmoBoxDocument* get_root() { return m_root; }
 
54
    int get_num_pages();
 
55
 
 
56
protected:
 
57
 
 
58
    //void create_shapes();
 
59
    //void layout_model();
 
60
    //void render_model();
 
61
 
 
62
};
 
63
 
 
64
 
 
65
//Abstract class from which all graphic objects must derive
 
66
//------------------------------------------------------------------------------
 
67
class GmoObj
 
68
{
 
69
protected:
 
70
    GmoObj* m_pOwnerGmo;
 
71
 
 
72
public:
 
73
    GmoObj(GmoObj* owner);
 
74
    virtual ~GmoObj();
 
75
 
 
76
};
 
77
 
 
78
//------------------------------------------------------------------------------
 
79
class GmoBox : public GmoObj
 
80
{
 
81
protected:
 
82
    std::vector<GmoBox*> m_childBoxes;
 
83
 
 
84
public:
 
85
    GmoBox(GmoObj* owner) : GmoObj(owner) {}
 
86
    virtual ~GmoBox() {}
 
87
 
 
88
    //child boxes
 
89
    inline int get_num_children() { return static_cast<int>( m_childBoxes.size() ); }
 
90
    inline void add_child_box(GmoBox* child) { m_childBoxes.push_back(child); }
 
91
    GmoBox* GmoBox::get_child_box(int i);  //i = 0..n-1
 
92
 
 
93
};
 
94
 
 
95
//------------------------------------------------------------------------------
 
96
class GmoShape : public GmoObj
 
97
{
 
98
protected:
 
99
 
 
100
public:
 
101
    GmoShape(GmoObj* owner) : GmoObj(owner) {}
 
102
    virtual ~GmoShape() {}
 
103
 
 
104
};
 
105
 
 
106
//------------------------------------------------------------------------------
 
107
class GmoBoxDocument : public GmoBox
 
108
{
 
109
protected:
 
110
 
 
111
public:
 
112
    GmoBoxDocument();
 
113
    ~GmoBoxDocument() {}
 
114
 
 
115
    //doc pages
 
116
    GmoBoxDocPage* add_new_page();
 
117
    GmoBoxDocPage* get_page(int i);     //i = 0..n-1
 
118
    inline int get_num_pages() { return get_num_children(); }
 
119
};
 
120
 
 
121
//------------------------------------------------------------------------------
 
122
class GmoBoxDocPage : public GmoBox
 
123
{
 
124
protected:
 
125
    int m_numPage;
 
126
 
 
127
public:
 
128
    GmoBoxDocPage(GmoObj* owner);
 
129
    ~GmoBoxDocPage() {}
 
130
 
 
131
    inline void set_number(int num) { m_numPage = num; }
 
132
    inline int get_number() { return m_numPage; }
 
133
 
 
134
};
 
135
 
 
136
//------------------------------------------------------------------------------
 
137
class GmoBoxScore : public GmoBox
 
138
{
 
139
protected:
 
140
 
 
141
public:
 
142
    GmoBoxScore(GmoObj* owner) : GmoBox(owner) {}
 
143
    ~GmoBoxScore() {}
 
144
 
 
145
};
 
146
 
 
147
 
 
148
 
 
149
}   //namespace lomse
 
150
 
 
151
#endif      //__LOMSE_GM_BASIC_H__