File indexing completed on 2024-05-12 16:34:16

0001 /* This file is part of the KDE project
0002  * Copyright 2007 Marijn Kruisselbrink <mkruisselbrink@kde.org>
0003  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Library General Public
0006  * License as published by the Free Software Foundation; either
0007  * version 2 of the License, or (at your option) any later version.
0008  *
0009  * This library is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012  * Library General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU Library General Public License
0015  * along with this library; see the file COPYING.LIB.  If not, write to
0016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018  */
0019 #ifndef MUSIC_SHAPE
0020 #define MUSIC_SHAPE
0021 
0022 #include <KoShape.h>
0023 #include <KoFrameShape.h>
0024 
0025 #define MusicShapeId "MusicShape"
0026 
0027 namespace MusicCore {
0028     class Sheet;
0029 }
0030 
0031 class MusicRenderer;
0032 class MusicStyle;
0033 class Engraver;
0034 
0035 class MusicShape : public KoShape, public KoFrameShape
0036 {
0037 public:
0038     MusicShape();
0039     ~MusicShape() override;
0040     /// reimplemented
0041     void paint( QPainter& painter, const KoViewConverter& converter, KoShapePaintingContext &paintcontext) override;
0042     void constPaint( QPainter& painter, const KoViewConverter& converter ) const;
0043 
0044     /// reimplemented
0045     void setSize( const QSizeF &newSize ) override;
0046 
0047     /// reimplemented
0048     void saveOdf( KoShapeSavingContext & context ) const override;
0049     // reimplemented
0050     bool loadOdf( const KoXmlElement & element, KoShapeLoadingContext &context ) override;
0051 
0052     MusicCore::Sheet* sheet();
0053     void setSheet(MusicCore::Sheet* sheet, int firstSystem);
0054     int firstSystem() const;
0055     void setFirstSystem(int system);
0056     int lastSystem() const;
0057     int firstBar() const;
0058     int lastBar() const;
0059     MusicRenderer* renderer();
0060     MusicStyle* style();
0061     void engrave(bool engraveBars=true);
0062 
0063     MusicShape* successor() { return m_successor; }
0064     MusicShape* predecessor() { return m_predecessor; }
0065 protected:
0066     // reimplemented
0067     bool loadOdfFrameElement( const KoXmlElement & element, KoShapeLoadingContext & context ) override;
0068 private:
0069     MusicCore::Sheet* m_sheet;
0070     int m_firstSystem;
0071     int m_lastSystem;
0072     MusicStyle* m_style;
0073     Engraver* m_engraver;
0074     MusicRenderer* m_renderer;
0075     MusicShape* m_successor;
0076     MusicShape* m_predecessor;
0077 };
0078 
0079 
0080 #endif // MUSIC_SHAPE