1
2
3
4
5
6
7
8
9
10 """
11 Code to handle setting colors for fields in various BitPim Editor Dialogs.
12 The idea is to show which fields are supported by the current phone model,
13 which fields are not, and which fields are unknown (default).
14
15 To use/enable this feature for your phone, define a dict value in your phone
16 profile that specifies the applicability of various fields. It's probably best
17 if you copy the default_field_info dict to your phone profile and set
18 appropriate values. The value of each key can be either:
19 None (don't know),
20 True (applicable),
21 False (not applicable),
22 0 (not applicable),
23 int>0 (number of entries this phone can have).
24
25 The name of this dict is 'field_color_data'. An example is included in module
26 com_lgvx9800.
27
28 """
29
30 import wx
31
32 applicable_color=wx.BLUE
33 notapplicable_color=wx.RED
34 dunno_color=wx.BLACK
35
36 default_field_info={
37 'phonebook': {
38 'name': {
39 'first': None, 'middle': None, 'last': None, 'full': None,
40 'nickname': None },
41 'number': {
42 'type': None, 'speeddial': None, 'number': None,
43 'ringtone': None, 'wallpaper': None },
44 'email': None,
45 'email_details': {
46 'emailspeeddial': None, 'emailringtone': None,
47 'emailwallpaper': None },
48 'address': {
49 'type': None, 'company': None, 'street': None, 'street2': None,
50 'city': None, 'state': None, 'postalcode': None, 'country': None },
51 'url': None,
52 'memo': None,
53 'category': None,
54 'wallpaper': None,
55 'ringtone': None,
56 'storage': None,
57 'secret': None,
58 'ICE': None,
59 'im': None,
60 },
61 'calendar': {
62 'description': None, 'location': None, 'allday': None,
63 'start': None, 'end': None, 'priority': None,
64 'alarm': None, 'vibrate': None,
65 'repeat': None,
66 'memo': None,
67 'category': None,
68 'wallpaper': None,
69 'ringtone': None,
70 },
71 'memo': {
72 'subject': None,
73 'date': None,
74 'secret': None,
75 'category': None,
76 'memo': None,
77 },
78 'todo': {
79 'summary': None,
80 'status': None,
81 'due_date': None,
82 'percent_complete': None,
83 'completion_date': None,
84 'private': None,
85 'priority': None,
86 'category': None,
87 'memo': None,
88 },
89 }
90
91 current_field_info=default_field_info
92
93
95 """Return the dict info for this widget
96 """
97 global current_field_info
98 _parent=widget.GetParent()
99 if name:
100 _names=[name]
101 else:
102 _names=[]
103 while _parent:
104 if hasattr(_parent, 'color_field_name'):
105 if _parent.color_field_name not in _names:
106 _names.append(_parent.color_field_name)
107 _parent=_parent.GetParent()
108 _names.reverse()
109 _dict=current_field_info
110 for n in _names:
111 if not _dict.has_key(n):
112 _dict[n]={}
113 _dict=_dict[n]
114 return _dict
115
117 """Return the number of sibblings to this widget
118 """
119 _parent=widget.GetParent()
120 _cnt=0
121 if _parent:
122 for _w in _parent.GetChildren():
123 if isinstance(_w, widget.__class__):
124 _cnt+=1
125 return _cnt
126
139
140 -def color(widget, name, tree=None):
160
162 """
163 instantiate the widget, set the color, and return the widget
164 """
165 _w=klass(*args)
166 if _w:
167 _w.SetForegroundColour(color(widget, name, tree))
168 return _w
169
175