openlp/openlp/core/theme/theme.py
2008-11-26 20:15:49 +00:00

91 lines
3.1 KiB
Python

"""
OpenLP - Open Source Lyrics Projection
Copyright (c) 2008 Raoul Snyman
Portions copyright (c) 2008 Martin Thompson, Tim Bentley
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; version 2 of the License.
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, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA
"""
import sys
import os
from PyQt4 import QtGui
sys.path.append(os.path.abspath("./../.."))
from openlp.core.xmlrootclass import XmlRootClass
blankstylexml=\
'''<?xml version="1.0" encoding="iso-8859-1"?>
<Theme>
<Name>BlankStyle</Name>
<BackgroundType>0</BackgroundType>
<BackgroundParameter1>$000000</BackgroundParameter1>
<BackgroundParameter2/>
<BackgroundParameter3/>
<FontName>Arial</FontName>
<FontColor>clWhite</FontColor>
<FontProportion>30</FontProportion>
<Shadow>0</Shadow>
<Outline>0</Outline>
<HorizontalAlign>0</HorizontalAlign>
<VerticalAlign>0</VerticalAlign>
<WrapStyle>0</WrapStyle>
</Theme>
'''
class Theme(XmlRootClass):
def __init__(self, xmlfile=None):
""" stores the info about a theme
attributes:
name : theme name
BackgroundType : 0 - solid color
1 - gradient color
2 - image
BackgroundParameter1 : for image - filename
for gradient - start color
for solid - color
BackgroundParameter2 : for image - border colour
for gradient - end color
for solid - N/A
BackgroundParameter3 : for image - N/A
for gradient - 0 -> vertical, 1 -> horizontal
FontName : name of font to use
FontColor : color for main font
FontProportion : point size of font
Shadow : 0 - no shadow, non-zero use shadow
ShadowColor : color for drop shadow
Outline : 0 - no outline, non-zero use outline
OutlineColor : color for outline (or None for no outline)
HorizontalAlign : 0 - left align
1 - right align
2 - centre align
VerticalAlign : 0 - top align
1 - bottom align
2 - centre align
WrapStyle : 0 - normal
1 - lyrics
"""
# init to defaults
self._set_from_XML(blankstylexml)
if xmlfile != None:
# init from xmlfile
file=open(xmlfile)
t=''.join(file.readlines()) # read the file and change list to a string
self._set_from_XML(t)