~ubuntu-branches/ubuntu/utopic/taskcoach/utopic-proposed

« back to all changes in this revision

Viewing changes to .pc/interpreter_name_for_smartdatetimectrl.diff/taskcoachlib/thirdparty/smartdatetimectrl.py

  • Committer: Package Import Robot
  • Author(s): Nicolas Boulenguez
  • Date: 2014-02-04 22:18:31 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20140204221831-elzdaymaom6vnjyd
Tags: 1.3.35-1
* New upstream release. Rebuild closes: #737604.
* Exclude unused thirdparties from repackaged upstream.
* Run upstream integration tests, both in rules and tests/control.
  Many Build-Depends added by the tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
358
358
            kwargs['style'] = wx.WANTS_CHARS
359
359
        super(Entry, self).__init__(*args, **kwargs)
360
360
 
361
 
        dc = wx.ClientDC(self)
362
 
        dc.SetFont(wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT))
363
 
 
364
361
        self.__focus = None
365
362
        self.__forceFocus = False
366
363
        self.__fields = list()
369
366
        self.__popup = None
370
367
        self.__focusStamp = time.time()
371
368
 
372
 
        minW = 0
373
 
        minH = 0
374
 
        curX = self.MARGIN
 
369
        self.__minW = 0
 
370
        self.__minH = 0
 
371
        self.__curX = self.MARGIN
375
372
 
376
373
        for state, keywords in format:
377
374
            field = state.createField(observer=self, **keywords)
378
 
            if state.valueName is not None:
379
 
                self.__namedFields[state.valueName] = field
380
 
 
381
 
            if isinstance(field, (str, unicode)):
382
 
                tw, th = dc.GetTextExtent(field)
383
 
                self.__widgets.append((field, curX, self.MARGIN, tw, th))
384
 
                minW += tw
385
 
                minH = max(minH, th)
386
 
                curX += tw + self.MARGIN
387
 
            else:
388
 
                self.__fields.append(field)
389
 
                w, h = field.GetExtent(dc)
390
 
                self.__widgets.append((field, curX, self.MARGIN, w, h))
391
 
                minW += w
392
 
                minH = max(minH, h)
393
 
                curX += w + self.MARGIN
 
375
            self.AddField(state.valueName, field)
394
376
 
395
377
        self.__SetFocus(self.__widgets[0][0])
396
378
 
397
 
        self.SetMinSize(wx.Size(minW + (len(self.__widgets) + 1) * self.MARGIN, minH + 2 * self.MARGIN))
398
 
 
399
379
        timerId = wx.NewId()
400
380
        self.__timer = wx.Timer(self, timerId)
401
381
        wx.EVT_TIMER(self, timerId, self.OnTimer)
406
386
        wx.EVT_KILL_FOCUS(self, self.OnKillFocus)
407
387
        wx.EVT_SET_FOCUS(self, self.OnSetFocus)
408
388
 
 
389
    def AddField(self, name, field):
 
390
        dc = wx.ClientDC(self)
 
391
        dc.SetFont(wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT))
 
392
 
 
393
        if name is not None:
 
394
            self.__namedFields[name] = field
 
395
        self.__fields.append(field)
 
396
 
 
397
        if isinstance(field, (str, unicode)):
 
398
            tw, th = dc.GetTextExtent(field)
 
399
            self.__widgets.append((field, self.__curX, self.MARGIN, tw, th))
 
400
            self.__minW += tw
 
401
            self.__minH = max(self.__minH, th)
 
402
            self.__curX += tw + self.MARGIN
 
403
        else:
 
404
            w, h = field.GetExtent(dc)
 
405
            self.__widgets.append((field, self.__curX, self.MARGIN, w, h))
 
406
            self.__minW += w
 
407
            self.__minH = max(self.__minH, h)
 
408
            self.__curX += w + self.MARGIN
 
409
 
 
410
        self.SetMinSize(wx.Size(self.__minW + (len(self.__widgets) + 1) * self.MARGIN, self.__minH + 2 * self.MARGIN))
 
411
 
409
412
    def Cleanup(self):
410
413
        # It's complicated.
411
414
        try:
467
470
        klass.formats.insert(0, format)
468
471
 
469
472
    def Fields(self):
470
 
        return self.__fields[:]
 
473
        return [field for field in self.__fields if isinstance(field, Field)]
471
474
 
472
475
    def Field(self, name):
473
476
        return self.__namedFields.get(name, NullField)
485
488
 
486
489
    def GetValue(self):
487
490
        value = list()
488
 
        for field in self.__fields:
 
491
        for field in self.Fields():
489
492
            value.append(field.GetValue())
490
493
        return tuple(value)
491
494
 
492
495
    def SetValue(self, value):
493
496
        value = list(value)
494
 
        for index, field in enumerate(self.__fields):
 
497
        for index, field in enumerate(self.Fields()):
495
498
            field.SetValue(value[index])
496
499
 
497
500
    def ValidateChange(self, field, value):
537
540
 
538
541
    def FocusNext(self):
539
542
        if self.__focus is not None:
540
 
            self.__SetFocus(self.__fields[(self.__fields.index(self.__focus) + 1) % len(self.__fields)])
 
543
            self.__SetFocus(self.Fields()[(self.Fields().index(self.__focus) + 1) % len(self.Fields())])
541
544
 
542
545
    def OnChar(self, event):
543
546
        if event.GetKeyCode() == wx.WXK_TAB:
560
563
                    wx.TheClipboard.GetData(data)
561
564
                    values = list()
562
565
                    for idx, mt in enumerate(self._rx_paste.finditer(data.GetText())):
563
 
                        values.append((mt.group(0), self.__fields[idx] if idx < len(self.__fields) else NullField))
 
566
                        values.append((mt.group(0), self.Fields()[idx] if idx < len(self.Fields()) else NullField))
564
567
                    self.OnPaste(values)
565
568
                finally:
566
569
                    wx.TheClipboard.Close()
580
583
            self.FocusNext()
581
584
        elif event.GetKeyCode() == wx.WXK_LEFT:
582
585
            if self.__focus is not None:
583
 
                self.__SetFocus(self.__fields[(self.__fields.index(self.__focus) + len(self.__fields) - 1) % len(self.__fields)])
 
586
                self.__SetFocus(self.Fields()[(self.Fields().index(self.__focus) + len(self.Fields()) - 1) % len(self.Fields())])
584
587
        elif event.GetKeyCode() == wx.WXK_ESCAPE and self.__popup is not None:
585
588
            self.__popup[0].Dismiss()
586
589
        elif event.GetKeyCode() == wx.WXK_RETURN and self.__popup is None and \
1312
1315
        if '__WXMAC__' in wx.PlatformInfo:
1313
1316
            wx.EVT_KILL_FOCUS(self, self.__OnKillFocus)
1314
1317
 
 
1318
        if self.Field('day') is NullField:
 
1319
            self.AddField(None, ' ')
 
1320
            self.AddField('day', DayField(value=self.__value.day, observer=self, width=2))
 
1321
        if self.Field('month') is NullField:
 
1322
            self.AddField(None, ' ')
 
1323
            self.AddField('month', AbbreviatedMonthField(value=self.__value.month, observer=self))
 
1324
        if self.Field('year') is NullField:
 
1325
            self.AddField(None, ' ')
 
1326
            self.AddField('year', YearField(value=self.__value.year, observer=self, width=4))
 
1327
 
1315
1328
    def Format(self):
1316
1329
        return self.__formatter(self.GetDate())
1317
1330