def _calculateWorkHour( self ): """ Do the calculation for work hour TO-DO: Make a better calculation!! """ # Update the current date according to for i in ( self._startingHour, self._startingPauseHour, self._endingPauseHour, self._endingPauseHour ): i = utils.copyDate( self._currentDate ) # Create the list self._lstDisplayedHours = [] if self._showOnlyWorkHour: morningWorkTime = range( self._startingHour.GetHour(), self._startingPauseHour.GetHour() ) afternoonWorkTime = range( self._endingPauseHour.GetHour(), self._endingHour.GetHour() ) rangeWorkHour = morningWorkTime + afternoonWorkTime else: # Show all the hours rangeWorkHour = range( self._startingHour.GetHour(), self._endingHour.GetHour() ) for H in rangeWorkHour: for M in ( 0, 30 ): hour = wx.DateTime().Now() hour = utils.copyDate( self._currentDate ) hour.SetHour( H ) hour.SetMinute( M ) self._lstDisplayedHours.append( hour )
def _calculateWorkHour(self): """ Do the calculation for work hour TO-DO: Make a better calculation!! """ # Update the current date according to for i in (self._startingHour, self._startingPauseHour, self._endingPauseHour, self._endingPauseHour): i = utils.copyDate(self._currentDate) # Create the list self._lstDisplayedHours = [] if self._showOnlyWorkHour: morningWorkTime = range(self._startingHour.GetHour(), self._startingPauseHour.GetHour()) afternoonWorkTime = range(self._endingPauseHour.GetHour(), self._endingHour.GetHour()) rangeWorkHour = list(morningWorkTime) + list(afternoonWorkTime) else: # Show all the hours rangeWorkHour = range(self._startingHour.GetHour(), self._endingHour.GetHour()) for H in rangeWorkHour: for M in (0, 30): hour = wx.DateTime().Now() hour = utils.copyDate(self._currentDate) hour.SetHour(H) hour.SetMinute(M) self._lstDisplayedHours.append(hour)
def DoPaint(self, drawer, x, y, width, height): self._schedulesCoords = list() self._datetimeCoords = list() day = utils.copyDate(self.GetDate()) if self._viewType == wxSCHEDULER_DAILY: return self._paintDaily(drawer, day, x, y, width, height) elif self._viewType == wxSCHEDULER_WEEKLY: return self._paintWeekly(drawer, day, x, y, width, height) elif self._viewType == wxSCHEDULER_MONTHLY: return self._paintMonthly(drawer, day, x, y, width, height)
def _OnPaintHeaders(self, evt): dc = wx.PaintDC(self._headerPanel) if 'phoenix' not in wx.PlatformInfo: dc.BeginDrawing() try: dc.SetBackground(wx.Brush(SCHEDULER_BACKGROUND_BRUSH)) dc.SetPen(FOREGROUND_PEN) dc.Clear() dc.SetFont(wx.NORMAL_FONT) if self._drawerClass.use_gc: context = wx.GraphicsContext.Create(dc) else: context = dc drawer = self._drawerClass(context, self._lstDisplayedHours) if self._resizable: width, _ = self.GetVirtualSize() else: width, _ = self.CalcMinSize() day = utils.copyDate(self.GetDate()) x, y = 0, 0 # Take horizontal scrolling into account x0, _ = self.GetViewStart() xu, _ = self.GetScrollPixelsPerUnit() x0 *= xu x -= x0 if self._viewType == wxSCHEDULER_DAILY: if self._style == wxSCHEDULER_VERTICAL: x += LEFT_COLUMN_SIZE width -= LEFT_COLUMN_SIZE theDay = utils.copyDateTime(day) maxDY = 0 for idx in xrange(self._periodCount): _, h = self._paintDailyHeaders( drawer, theDay, x + 1.0 * width / self._periodCount * idx, y, 1.0 * width / self._periodCount, 36) maxDY = max(maxDY, h) theDay.AddDS(wx.DateSpan(days=1)) h = maxDY elif self._viewType == wxSCHEDULER_WEEKLY: if self._style == wxSCHEDULER_VERTICAL: x += LEFT_COLUMN_SIZE width -= LEFT_COLUMN_SIZE theDay = utils.copyDateTime(day) maxDY = 0 for idx in xrange(self._periodCount): h = self._paintWeeklyHeaders( drawer, theDay, x + 1.0 * width / self._periodCount * idx, y, 1.0 * width / self._periodCount, 36) maxDY = max(maxDY, h) theDay.AddDS(wx.DateSpan(weeks=1)) h = maxDY elif self._viewType == wxSCHEDULER_MONTHLY: _, h = self._paintMonthlyHeaders(drawer, day, x, y, width, 36) minW, minH = self._headerPanel.GetMinSize() if minH != h: self._headerPanel.SetMinSize(wx.Size(-1, h)) self._headerPanel.GetParent().Layout() finally: if 'phoenix' not in wx.PlatformInfo: dc.EndDrawing()
def _OnPaintHeaders( self, evt ): dc = wx.PaintDC( self._headerPanel ) if 'phoenix' not in wx.PlatformInfo: dc.BeginDrawing() try: dc.SetBackground( wx.Brush( SCHEDULER_BACKGROUND_BRUSH ) ) dc.SetPen( FOREGROUND_PEN ) dc.Clear() dc.SetFont( wx.NORMAL_FONT ) if self._drawerClass.use_gc: context = wx.GraphicsContext.Create(dc) else: context = dc drawer = self._drawerClass(context, self._lstDisplayedHours) if self._resizable: width, _ = self.GetVirtualSize() else: width, _ = self.CalcMinSize() day = utils.copyDate(self.GetDate()) x, y = 0, 0 # Take horizontal scrolling into account x0, _ = self.GetViewStart() xu, _ = self.GetScrollPixelsPerUnit() x0 *= xu x -= x0 if self._viewType == wxSCHEDULER_DAILY: if self._style == wxSCHEDULER_VERTICAL: x += LEFT_COLUMN_SIZE width -= LEFT_COLUMN_SIZE theDay = utils.copyDateTime(day) maxDY = 0 for idx in xrange(self._periodCount): _, h = self._paintDailyHeaders(drawer, theDay, x + 1.0 * width / self._periodCount * idx, y, 1.0 * width / self._periodCount, 36) maxDY = max(maxDY, h) theDay.AddDS(wx.DateSpan(days=1)) h = maxDY elif self._viewType == wxSCHEDULER_WEEKLY: if self._style == wxSCHEDULER_VERTICAL: x += LEFT_COLUMN_SIZE width -= LEFT_COLUMN_SIZE theDay = utils.copyDateTime(day) maxDY = 0 for idx in xrange(self._periodCount): h = self._paintWeeklyHeaders(drawer, theDay, x + 1.0 * width / self._periodCount * idx, y, 1.0 * width / self._periodCount, 36) maxDY = max(maxDY, h) theDay.AddDS(wx.DateSpan(weeks=1)) h = maxDY elif self._viewType == wxSCHEDULER_MONTHLY: _, h = self._paintMonthlyHeaders(drawer, day, x, y, width, 36) minW, minH = self._headerPanel.GetMinSize() if minH != h: self._headerPanel.SetMinSize(wx.Size(-1, h)) self._headerPanel.GetParent().Layout() finally: if 'phoenix' not in wx.PlatformInfo: dc.EndDrawing()