...
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from .base_objects import MonthlyCalendarObject, WeekDayNameObject, DailyCalendarObject, WeekNameObject
|
||||
from .base_objects import MonthlyCalendarObject, WeekDayNameObject, DailyCalendarObject, WeekNameObject, MonthNameObject
|
||||
from .calendar_helpers import MonthCalendarMatrix
|
||||
import calendar
|
||||
import math
|
||||
@@ -13,41 +13,114 @@ def class_from_name(className):
|
||||
class SimpleWeekDayNameObject(WeekDayNameObject):
|
||||
def __init__(self):
|
||||
WeekDayNameObject.__init__(self, "SimpleWeekDayNameObject")
|
||||
self.noStub = True
|
||||
|
||||
def plotObject(self):
|
||||
textBox = scribus.createText(self.position[0],self.position[1], self.size[0],self.size[1])
|
||||
scribus.setStyle(self.paragraphStyle, textBox )
|
||||
scribus.insertText(self.getNameAbbrev(), 0, textBox )
|
||||
scribus.sentToLayer(self.layer, textBox)
|
||||
|
||||
class SimpleMonthNameObject(MonthNameObject):
|
||||
def __init__(self):
|
||||
MonthNameObject.__init__(self, "SimpleMonthNameObject")
|
||||
|
||||
def plotObject(self):
|
||||
textBox = scribus.createText(self.position[0],self.position[1], self.size[0],self.size[1])
|
||||
scribus.setStyle(self.paragraphStyle, textBox )
|
||||
scribus.insertText(self.getMonthName(), 0, textBox )
|
||||
scribus.sentToLayer(self.layer, textBox)
|
||||
|
||||
class SimpleWeekNameObject(WeekNameObject):
|
||||
def __init__(self):
|
||||
WeekNameObject.__init__(self, "SimpleWeekNameObject")
|
||||
self.noStub = True
|
||||
|
||||
def plotObject(self):
|
||||
textBox = scribus.createText(self.position[0],self.position[1], self.size[0],self.size[1])
|
||||
scribus.setStyle(self.paragraphStyle, textBox )
|
||||
scribus.insertText(self.getNameAbbrev(), 0, textBox )
|
||||
scribus.sentToLayer(self.layer, textBox)
|
||||
|
||||
|
||||
class FormattedDayObject(DailyCalendarObject):
|
||||
def __init__(self):
|
||||
DailyCalendarObject.__init__(self,"FormattedDayObject")
|
||||
self.noStub = True
|
||||
|
||||
self.paragraphStyle = "S"
|
||||
self.paragraphStyle = [
|
||||
'DayLetterParagraphStyle',
|
||||
'DayLetterHighlightParagraphStyle',
|
||||
'EventParagraphStyle']
|
||||
|
||||
self.charStyle = [
|
||||
'DayLetterCharStyle',
|
||||
'DayLetterHighlightCharStyle',
|
||||
'EventCharStyle']
|
||||
|
||||
self.defaultFontSize = [ 8, 8, 4]
|
||||
|
||||
def plotObject(self):
|
||||
if self.isActive:
|
||||
textBox = scribus.createText(self.position[0],self.position[1], self.size[0],self.size[1])
|
||||
heightEventBox = self.size[1] * self.heightEventbox
|
||||
heightLetterBox = self.size[1] * ( 1 - self.heightEventbox )
|
||||
|
||||
widthHolidaybox = self.size[0] * self.widthHolidaybox
|
||||
widthLetterbox = self.size[0] * ( 1 - self.widthHolidaybox)
|
||||
|
||||
dayLetterBox = [ self.position[0]
|
||||
,self.position[1]
|
||||
,widthLetterbox
|
||||
,heightLetterBox ]
|
||||
|
||||
eventNameBox = [ self.position[0]
|
||||
,self.position[1] + heightLetterBox
|
||||
,self.size[0]
|
||||
,heightEventBox ]
|
||||
|
||||
holidayBox = [ self.position[0] + widthLetterbox
|
||||
,self.position[1]
|
||||
,widthHolidaybox
|
||||
,heightLetterBox ]
|
||||
|
||||
bankHolidayEvent = self.configParser.getEvent(self.date, "bankHolidays")
|
||||
schoolHolidayEvent = self.configParser.getEvent(self.date, "schoolHolidays")
|
||||
|
||||
dayLetterStyle = self.paragraphStyle[0]
|
||||
if bankHolidayEvent is not None:
|
||||
if ( bankHolidayEvent[1]["hint"] == "" ):
|
||||
dayLetterStyle = self.paragraphStyle[1]
|
||||
|
||||
eventNameTextBox = scribus.createText(*eventNameBox)
|
||||
scribus.insertText(bankHolidayEvent[1]["name"], 0, eventNameTextBox )
|
||||
scribus.setStyle(self.paragraphStyle[2], eventNameTextBox)
|
||||
scribus.sentToLayer(self.layer, eventNameTextBox)
|
||||
|
||||
if schoolHolidayEvent is not None:
|
||||
holidayTextbox = scribus.createText(*holidayBox)
|
||||
scribus.insertText("F", 0, holidayTextbox )
|
||||
scribus.setStyle(self.paragraphStyle[2], holidayTextbox)
|
||||
scribus.sentToLayer(self.layer, holidayTextbox)
|
||||
|
||||
textBox = scribus.createText(*dayLetterBox)
|
||||
scribus.setStyle(dayLetterStyle, textBox )
|
||||
scribus.insertText(self.getName(), 0, textBox )
|
||||
scribus.sentToLayer(self.layer, textBox)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class DayGridObject(DailyCalendarObject):
|
||||
def __init__(self):
|
||||
DailyCalendarObject.__init__(self,"DayGridObject")
|
||||
self.noStub = True
|
||||
|
||||
|
||||
def plotObject(self):
|
||||
if self.isActive:
|
||||
textBox = scribus.createText(self.position[0],self.position[1], self.size[0],self.size[1])
|
||||
scribus.setStyle(self.paragraphStyle, textBox )
|
||||
scribus.insertText(self.getName(), 0, textBox )
|
||||
scribus.sentToLayer(self.layer, textBox)
|
||||
|
||||
@@ -66,6 +139,7 @@ class MonthlyGrid(MonthlyCalendarObject):
|
||||
self.calendarWeekClass = None
|
||||
self.weekDayClass = None
|
||||
self.dayClass = None
|
||||
self.monthNameClass = None
|
||||
|
||||
|
||||
self.createdObjects = []
|
||||
@@ -83,6 +157,15 @@ class MonthlyGrid(MonthlyCalendarObject):
|
||||
self.scaleFactor[0] = self.size[0] / unitsX
|
||||
self.scaleFactor[1] = self.size[1] / unitsY
|
||||
|
||||
def createStyles(self, existing_styles):
|
||||
self.initSubObjects()
|
||||
|
||||
MonthlyCalendarObject.createStyles(self, existing_styles)
|
||||
|
||||
self.weekDayClass().createStyles(existing_styles)
|
||||
self.dayClass().createStyles(existing_styles)
|
||||
self.calendarWeekClass().createStyles(existing_styles)
|
||||
|
||||
def setDate(self, date):
|
||||
MonthlyCalendarObject.setDate(self, date)
|
||||
if self.oneLineOnly:
|
||||
@@ -101,11 +184,11 @@ class MonthlyGrid(MonthlyCalendarObject):
|
||||
|
||||
def plotObject(self):
|
||||
self.createObjects()
|
||||
|
||||
for obj in self.createdObjects:
|
||||
obj.plotObject()
|
||||
|
||||
def createObjects(self):
|
||||
|
||||
def initSubObjects(self):
|
||||
if type(self.weekDayClass) == unicode :
|
||||
self.weekDayClass = class_from_name(self.weekDayClass)
|
||||
|
||||
@@ -115,6 +198,10 @@ class MonthlyGrid(MonthlyCalendarObject):
|
||||
if type(self.calendarWeekClass) == unicode:
|
||||
self.calendarWeekClass = class_from_name(self.calendarWeekClass)
|
||||
|
||||
|
||||
def createObjects(self):
|
||||
self.initSubObjects()
|
||||
|
||||
self.createdObjects = []
|
||||
w = self.position[0]
|
||||
h = self.position[1]
|
||||
@@ -147,6 +234,7 @@ class MonthlyGrid(MonthlyCalendarObject):
|
||||
self.createdObjects.append(calendarWeekObj)
|
||||
|
||||
dailyObj = self.dayClass()
|
||||
dailyObj.configure(self.configParser)
|
||||
dailyObj.setDate(i[j])
|
||||
dailyObj.setActive(i[j].month == self.date.month)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user