1 # -*- coding: UTF-8 -*-
2 # vim: expandtab sw=4 ts=4 sts=4:
7 __author__
= 'Michal Čihař'
8 __email__
= 'michal@cihar.com'
10 Copyright © 2003 - 2010 Michal Čihař
12 This program is free software; you can redistribute it and/or modify it
13 under the terms of the GNU General Public License version 2 as published by
14 the Free Software Foundation.
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
21 You should have received a copy of the GNU General Public License along with
22 this program; if not, write to the Free Software Foundation, Inc.,
23 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 import wx
.lib
.editor
.editor
28 import wx
.lib
.mixins
.listctrl
31 import Wammu
.MessageDisplay
33 import Wammu
.PhoneValidator
35 import Wammu
.EditContactList
36 if Wammu
.gammu_error
== None:
41 class MessagePreview(wx
.Dialog
):
47 <p><wxp module="wx" class="Button">
48 <param name="id" value="ID_OK">
55 def __init__(self
, parent
, content
):
56 wx
.Dialog
.__init
__(self
, parent
, -1, _('Message preview'))
57 html
= wx
.html
.HtmlWindow(self
, -1, size
=(420, -1))
58 html
.SetPage(self
.text
% content
)
59 btn
= html
.FindWindowById(wx
.ID_OK
)
61 ir
= html
.GetInternalRepresentation()
62 html
.SetSize( (ir
.GetWidth()+25, ir
.GetHeight()+25) )
63 self
.SetClientSize(html
.GetSize())
64 self
.CentreOnParent(wx
.BOTH
)
66 class StyleEdit(wx
.Dialog
):
67 def __init__(self
, parent
, entry
):
68 wx
.Dialog
.__init
__(self
, parent
, -1, _('Text style'))
70 self
.sizer
= wx
.GridBagSizer()
81 for x
in Wammu
.Data
.TextFormats
:
85 self
.fmt
[name
] = wx
.CheckBox(self
, -1, text
)
86 if self
.entry
.has_key(name
):
87 self
.fmt
[name
].SetValue(self
.entry
[name
])
88 self
.sizer
.Add(self
.fmt
[name
], pos
= (row
, col
))
93 maxcol
= max(col
, maxcol
)
96 self
.sizer
.Add(wx
.StaticText(self
, -1, x
[0][0] + ':'), pos
= (row
, col
))
99 rb
= wx
.RadioButton(self
, -1, x
[0][1], style
= wx
.RB_GROUP
)
101 self
.sizer
.Add(rb
, pos
= (row
, col
))
103 for name
, text
, fmt
in x
[1:]:
104 self
.fmt
[name
] = wx
.RadioButton(self
, -1, text
)
105 if self
.entry
.has_key(name
):
106 self
.fmt
[name
].SetValue(self
.entry
[name
])
107 self
.sizer
.Add(self
.fmt
[name
], pos
= (row
, col
))
110 maxcol
= max(col
, maxcol
)
115 maxcol
= max(col
, maxcol
)
118 self
.ok
= wx
.Button(self
, wx
.ID_OK
)
119 self
.sizer
.Add(self
.ok
, pos
= (row
, 1), span
= wx
.GBSpan(colspan
= maxcol
), flag
= wx
.ALIGN_CENTER
)
120 wx
.EVT_BUTTON(self
, wx
.ID_OK
, self
.Okay
)
122 self
.sizer
.AddSpacer((5,5), pos
=(row
+ 1, maxcol
+ 1))
125 self
.SetAutoLayout(True)
126 self
.SetSizer(self
.sizer
)
128 self
.CentreOnParent(wx
.BOTH
)
131 for x
in Wammu
.Data
.TextFormats
:
132 for name
, text
, fmt
in x
[1:]:
133 self
.entry
[name
] = self
.fmt
[name
].GetValue()
134 self
.EndModal(wx
.ID_OK
)
136 class AutoSizeList(wx
.ListCtrl
, wx
.lib
.mixins
.listctrl
.ListCtrlAutoWidthMixin
):
137 def __init__(self
, parent
, firstcol
):
138 wx
.ListCtrl
.__init
__(self
, parent
, -1, style
=wx
.LC_REPORT | wx
.LC_HRULES | wx
.LC_VRULES | wx
.LC_SINGLE_SEL | wx
.SUNKEN_BORDER
, size
= (-1, 100))
139 self
.InsertColumn(0, firstcol
)
140 wx
.lib
.mixins
.listctrl
.ListCtrlAutoWidthMixin
.__init
__(self
)
142 class GenericEditor(wx
.Panel
):
144 Generic class for static text with some edit control.
146 def __init__(self
, parent
, part
, cfg
, unicode):
147 wx
.Panel
.__init
__(self
, parent
, -1, style
= wx
.RAISED_BORDER
)
150 self
.unicode = unicode
152 class TextEditor(GenericEditor
):
153 def __init__(self
, parent
, cfg
,part
, unicode):
154 GenericEditor
.__init
__(self
, parent
, cfg
, part
, unicode)
158 self
.sizer
= wx
.GridBagSizer()
160 self
.edit
= wx
.TextCtrl(self
, -1, style
=wx
.TE_MULTILINE
)
162 self
.sizer
.Add(self
.edit
, pos
= (0,0), flag
= wx
.EXPAND
, span
= wx
.GBSpan(colspan
= 4))
163 self
.sizer
.AddGrowableCol(1)
164 self
.sizer
.AddGrowableCol(2)
165 self
.sizer
.AddGrowableRow(0)
167 self
.concat
= wx
.CheckBox(self
, -1, _('Concatenated'))
168 self
.concat
.SetToolTipString(_('Create concatenated message, what allows to send longer messages.'))
169 self
.concat
.SetValue(self
.part
['ID'] != 'Text')
170 wx
.EVT_CHECKBOX(self
.concat
, self
.concat
.GetId(), self
.OnConcatChange
)
171 self
.sizer
.Add(self
.concat
, pos
= (1, 0), flag
= wx
.ALIGN_CENTER_VERTICAL
)
173 self
.leninfo
= wx
.StaticText(self
, -1, '')
174 self
.sizer
.Add(self
.leninfo
, pos
= (1, 3), flag
= wx
.ALIGN_RIGHT
)
176 self
.stylebut
= wx
.Button(self
, -1, _('Style'))
177 wx
.EVT_BUTTON(self
, self
.stylebut
.GetId(), self
.StylePressed
)
178 self
.sizer
.Add(self
.stylebut
, pos
= (1, 1), flag
= wx
.ALIGN_CENTER
)
180 self
.OnConcatChange()
182 wx
.EVT_TEXT(self
.edit
, self
.edit
.GetId(), self
.TextChanged
)
183 if self
.part
.has_key('Buffer'):
184 self
.edit
.SetValue(self
.part
['Buffer'])
187 self
.SetAutoLayout(True)
188 self
.SetSizer(self
.sizer
)
191 def OnUnicode(self
, newu
):
195 def OnConcatChange(self
, evt
= None):
196 self
.stylebut
.Enable(self
.concat
.GetValue())
199 def CheckTextLen(self
, evt
= None):
200 if not self
.concat
.GetValue():
202 self
.edit
.SetValue(self
.edit
.GetValue()[:70])
204 self
.edit
.SetValue(self
.edit
.GetValue()[:160])
206 def StylePressed(self
, evt
):
207 dlg
= StyleEdit(self
, self
.part
)
211 def TextChanged(self
, evt
= None):
212 txt
= self
.edit
.GetValue()
214 if not self
.concat
.GetValue() and ((self
.unicode and length
> 70) or (not self
.unicode and length
> 160)):
215 self
.edit
.SetValue(self
.backuptext
)
217 length
= len(self
.edit
.GetValue())
218 self
.leninfo
.SetLabel(Wammu
.Locales
.ngettext('%d char', '%d chars', length
) % length
)
220 self
.backuptext
= txt
223 if self
.concat
.GetValue():
224 if self
.cfg
.Read('/Message/16bitId') == 'yes':
225 self
.part
['ID'] = 'ConcatenatedTextLong16bit'
227 self
.part
['ID'] = 'ConcatenatedTextLong'
229 self
.part
['ID'] = 'Text'
230 self
.part
['Buffer'] = Wammu
.Locales
.UnicodeConv(self
.edit
.GetValue())
233 class PredefinedAnimEditor(GenericEditor
):
234 def __init__(self
, parent
, part
, cfg
, unicode):
235 GenericEditor
.__init
__(self
, parent
, part
, cfg
, unicode)
236 self
.sizer
= wx
.GridBagSizer()
239 for x
in Wammu
.Data
.PredefinedAnimations
:
242 self
.sizer
.AddGrowableRow(0)
243 self
.sizer
.AddGrowableCol(0)
244 self
.sizer
.AddGrowableCol(1)
245 self
.sizer
.AddGrowableCol(2)
247 self
.edit
= wx
.Choice(self
, -1, choices
= values
)
249 bitmap
= wx
.BitmapFromXPMData(Wammu
.Data
.UnknownPredefined
)
250 self
.bitmap
= wx
.StaticBitmap(self
, -1, bitmap
, (0,0))
252 wx
.EVT_CHOICE(self
.edit
, self
.edit
.GetId(), self
.OnChange
)
254 if not self
.part
.has_key('Number'):
255 self
.part
['Number'] = 0
257 self
.edit
.SetSelection(self
.part
['Number'])
260 self
.sizer
.Add(wx
.StaticText(self
, -1, _('Select predefined animation:')), pos
= (0,0), flag
= wx
.ALIGN_CENTER_VERTICAL
)
261 self
.sizer
.Add(self
.edit
, pos
= (0,1), flag
= wx
.ALIGN_CENTER
)
262 self
.sizer
.Add(self
.bitmap
, pos
= (0,2), flag
= wx
.ALIGN_CENTER
)
265 self
.SetAutoLayout(True)
266 self
.SetSizer(self
.sizer
)
268 def OnChange(self
, evt
= None):
269 bitmap
= wx
.BitmapFromXPMData(Wammu
.Data
.PredefinedAnimations
[self
.edit
.GetSelection()][1])
270 self
.bitmap
.SetBitmap(bitmap
)
273 self
.part
['ID'] = 'EMSPredefinedAnimation'
274 self
.part
['Number'] = self
.edit
.GetSelection()
277 class PredefinedSoundEditor(GenericEditor
):
278 def __init__(self
, parent
, part
, cfg
, unicode):
279 GenericEditor
.__init
__(self
, parent
, part
, cfg
, unicode)
280 self
.sizer
= wx
.GridBagSizer()
283 for x
in Wammu
.Data
.PredefinedSounds
:
286 self
.sizer
.AddGrowableRow(0)
287 self
.sizer
.AddGrowableCol(0)
288 self
.sizer
.AddGrowableCol(1)
290 self
.edit
= wx
.Choice(self
, -1, choices
= values
)
292 if not self
.part
.has_key('Number'):
293 self
.part
['Number'] = 0
295 self
.edit
.SetSelection(self
.part
['Number'])
297 self
.sizer
.Add(wx
.StaticText(self
, -1, _('Select predefined sound:')), pos
= (0,0), flag
= wx
.ALIGN_CENTER_VERTICAL
)
298 self
.sizer
.Add(self
.edit
, pos
= (0,1), flag
= wx
.ALIGN_CENTER
)
301 self
.SetAutoLayout(True)
302 self
.SetSizer(self
.sizer
)
305 self
.part
['ID'] = 'EMSPredefinedSound'
306 self
.part
['Number'] = self
.edit
.GetSelection()
310 # FIXME: should support more types...
311 # ID, display text, match types, editor, init type
312 (0, _('Text'), Wammu
.Data
.SMSIDs
['Text'], TextEditor
, 'ConcatenatedTextLong16bit'),
313 (1, _('Predefined animation'), Wammu
.Data
.SMSIDs
['PredefinedAnimation'], PredefinedAnimEditor
, 'EMSPredefinedAnimation'),
314 (2, _('Predefined sound'), Wammu
.Data
.SMSIDs
['PredefinedSound'], PredefinedSoundEditor
, 'EMSPredefinedSound'),
317 class SMSComposer(wx
.Dialog
):
318 def __init__(self
, parent
, cfg
, entry
, values
, action
= 'save', addtext
= True):
319 wx
.Dialog
.__init
__(self
, parent
, -1, _('Composing SMS'), style
= wx
.DEFAULT_DIALOG_STYLE | wx
.RESIZE_BORDER
)
323 if not entry
.has_key('SMSInfo'):
324 entry
['SMSInfo'] = {}
325 entry
['SMSInfo']['Entries'] = []
326 if self
.cfg
.Read('/Message/Concatenated') == 'yes':
327 if self
.cfg
.Read('/Message/16bitId') == 'yes':
328 typ
= 'ConcatenatedTextLong16bit'
330 typ
= 'ConcatenatedTextLong'
333 if entry
.has_key('Text'):
334 entry
['SMSInfo']['Entries'].append({'ID': typ
, 'Buffer': entry
['Text']})
336 entry
['SMSInfo']['Entries'].append({'ID': typ
, 'Buffer': ''})
337 if not entry
.has_key('Number'):
340 self
.sizer
= wx
.GridBagSizer()
345 if not action
in ['send', 'save']:
348 self
.send
= wx
.CheckBox(self
, -1, _('Send message'))
349 self
.send
.SetToolTipString(_('When checked, message is sent to recipient.'))
350 self
.send
.SetValue(action
== 'send')
352 self
.save
= wx
.CheckBox(self
, -1, _('Save into folder'))
353 self
.save
.SetToolTipString(_('When checked, message is saved to phone.'))
354 self
.save
.SetValue(action
== 'save')
356 self
.Bind(wx
.EVT_CHECKBOX
, self
.OnSave
, self
.save
)
357 self
.Bind(wx
.EVT_CHECKBOX
, self
.OnSend
, self
.send
)
359 self
.folder
= wx
.SpinCtrl(self
, -1, '2', style
= wx
.SP_WRAP|wx
.SP_ARROW_KEYS
, min = 0, max = 100, initial
= 2)
361 self
.sizer
.Add(self
.send
, pos
= (row
,1), flag
= wx
.ALIGN_LEFT
)
362 self
.sizer
.Add(self
.save
, pos
= (row
,6), flag
= wx
.ALIGN_LEFT
)
363 self
.sizer
.Add(self
.folder
, pos
= (row
,7), flag
= wx
.ALIGN_LEFT
)
367 self
.number
= wx
.TextCtrl(self
, -1, entry
['Number'], validator
= Wammu
.PhoneValidator
.PhoneValidator(multi
= True), size
= (150, -1))
368 self
.contbut
= wx
.Button(self
, -1, _('Add'))
369 self
.contbut
.SetToolTipString(_('Add number of recipient from contacts.'))
370 # TODO: when switching to wx 2.8, use wx.ID_EDIT
371 self
.editlistbut
= wx
.Button(self
, -1, _('Edit'))
372 self
.editlistbut
.SetToolTipString(_('Edit recipients list.'))
374 self
.sizer
.Add(wx
.StaticText(self
, -1, _('Recipient\'s numbers:')), pos
= (row
,1), flag
= wx
.ALIGN_LEFT | wx
.ALIGN_CENTER_VERTICAL
)
375 self
.sizer
.Add(self
.number
, pos
= (row
,2), flag
= wx
.ALIGN_CENTER_VERTICAL | wx
.EXPAND
, span
= wx
.GBSpan(colspan
= 4))
376 self
.sizer
.Add(self
.editlistbut
, pos
= (row
,6), flag
= wx
.ALIGN_CENTER
)
377 self
.sizer
.Add(self
.contbut
, pos
= (row
,7), flag
= wx
.ALIGN_CENTER
)
379 self
.Bind(wx
.EVT_BUTTON
, self
.ContactPressed
, self
.contbut
)
380 self
.Bind(wx
.EVT_BUTTON
, self
.EditContactPressed
, self
.editlistbut
)
384 self
.unicode = wx
.CheckBox(self
, -1, _('Unicode'))
385 self
.unicode.SetToolTipString(_('Unicode messages can contain national and other special characters, check this if you use non latin-1 characters. Your messages will require more space, so you can write less characters into single message.'))
386 if self
.entry
.has_key('Unicode'):
387 self
.unicode.SetValue(self
.entry
['Unicode'])
389 self
.unicode.SetValue(self
.cfg
.Read('/Message/Unicode') == 'yes')
391 self
.sizer
.Add(self
.unicode, pos
= (row
,1), flag
= wx
.ALIGN_LEFT
)
393 self
.Bind(wx
.EVT_CHECKBOX
, self
.OnUnicode
, self
.unicode)
395 self
.report
= wx
.CheckBox(self
, -1, _('Delivery report'))
396 self
.report
.SetToolTipString(_('Check to request delivery report for message.'))
397 self
.report
.SetValue(self
.cfg
.Read('/Message/DeliveryReport') == 'yes')
398 self
.sizer
.Add(self
.report
, pos
= (row
,2), flag
= wx
.ALIGN_LEFT
)
400 self
.sent
= wx
.CheckBox(self
, -1, _('Sent'))
401 self
.sent
.SetToolTipString(_('Check to save message as sent (has only effect when only saving message).'))
402 self
.sizer
.Add(self
.sent
, pos
= (row
,4), flag
= wx
.ALIGN_LEFT
)
404 self
.flash
= wx
.CheckBox(self
, -1, _('Flash'))
405 self
.flash
.SetToolTipString(_('Send flash message - it will be just displayed on display, but not saved in phone.'))
406 self
.sizer
.Add(self
.flash
, pos
= (row
,6), flag
= wx
.ALIGN_LEFT
)
410 self
.sizer
.AddGrowableRow(row
)
412 self
.current
= AutoSizeList(self
, _('Parts of current message'))
413 self
.available
= AutoSizeList(self
, _('Available message parts'))
416 self
.addbut
= wx
.Button(self
, wx
.ID_ADD
)
417 self
.delbut
= wx
.Button(self
, wx
.ID_REMOVE
)
419 self
.Bind(wx
.EVT_BUTTON
, self
.AddPressed
, self
.addbut
)
420 self
.Bind(wx
.EVT_BUTTON
, self
.DeletePressed
, self
.delbut
)
422 self
.sizer
.Add(self
.current
, pos
= (row
,1), flag
= wx
.EXPAND
, span
= wx
.GBSpan(colspan
= 2, rowspan
= 2))
423 self
.sizer
.Add(self
.addbut
, pos
= (row
,4), flag
= wx
.ALIGN_CENTER
)
424 self
.sizer
.Add(self
.delbut
, pos
= (row
+ 1,4), flag
= wx
.ALIGN_CENTER
)
425 self
.sizer
.Add(self
.available
, pos
= (row
,6), flag
= wx
.EXPAND
, span
= wx
.GBSpan(colspan
= 2, rowspan
= 2))
429 self
.upbut
= wx
.Button(self
, wx
.ID_UP
)
430 self
.dnbut
= wx
.Button(self
, wx
.ID_DOWN
)
432 self
.sizer
.Add(self
.upbut
, pos
= (row
,1), flag
= wx
.ALIGN_CENTER
)
433 self
.sizer
.Add(self
.dnbut
, pos
= (row
,2), flag
= wx
.ALIGN_CENTER
)
435 self
.Bind(wx
.EVT_BUTTON
, self
.UpPressed
, self
.upbut
)
436 self
.Bind(wx
.EVT_BUTTON
, self
.DnPressed
, self
.dnbut
)
439 self
.sizer
.AddGrowableRow(row
)
442 self
.editor
= wx
.StaticText(self
, -1, _('Create new message by adding part to left list...'), size
= (-1, 150))
443 self
.sizer
.Add(self
.editor
, pos
= (row
,1), flag
= wx
.EXPAND
, span
= wx
.GBSpan(colspan
= 7))
447 self
.preview
= wx
.Button(self
, -1, _('Preview'))
448 self
.button_sizer
= wx
.StdDialogButtonSizer()
449 self
.button_sizer
.AddButton(wx
.Button(self
, wx
.ID_OK
))
450 self
.button_sizer
.AddButton(wx
.Button(self
, wx
.ID_CANCEL
))
451 self
.button_sizer
.SetNegativeButton(self
.preview
)
452 self
.button_sizer
.Realize()
453 self
.sizer
.Add(self
.button_sizer
, pos
= (row
, 1), span
= wx
.GBSpan(colspan
= 7), flag
= wx
.ALIGN_RIGHT
)
455 self
.Bind(wx
.EVT_BUTTON
, self
.Okay
, id = wx
.ID_OK
)
456 self
.Bind(wx
.EVT_BUTTON
, self
.Preview
, self
.preview
)
458 self
.sizer
.AddSpacer((5,5), pos
=(row
+ 1,8))
459 self
.sizer
.AddGrowableCol(1)
460 self
.sizer
.AddGrowableCol(2)
461 self
.sizer
.AddGrowableCol(6)
462 self
.sizer
.AddGrowableCol(7)
464 self
.SetAutoLayout(True)
465 self
.SetSizer(self
.sizer
)
470 self
.Bind(wx
.EVT_LIST_ITEM_SELECTED
, self
.CurrentSelected
, self
.current
)
471 self
.Bind(wx
.EVT_LIST_ITEM_SELECTED
, self
.AvailableSelected
, self
.available
)
479 self
.available
.InsertImageStringItem(x
[0], x
[1], x
[0])
480 self
.available
.SetItemState(0, wx
.LIST_STATE_FOCUSED | wx
.LIST_STATE_SELECTED
, wx
.LIST_STATE_FOCUSED | wx
.LIST_STATE_SELECTED
)
482 self
.GenerateCurrent()
484 def ContactPressed(self
, evt
):
485 v
= Wammu
.Select
.SelectNumber(self
, [] + self
.values
['contact']['ME'] + self
.values
['contact']['SM'])
487 self
.number
.SetValue(self
.number
.GetValue() + ' ' + v
)
489 def EditContactPressed(self
, evt
):
491 Opens dialog for editing contact list.
493 contacts
= [] + self
.values
['contact']['ME'] + self
.values
['contact']['SM']
494 current
= self
.number
.GetValue()
495 dlg
= Wammu
.EditContactList
.EditContactList(self
, contacts
, current
)
496 if dlg
.ShowModal() == wx
.ID_OK
:
497 self
.number
.SetValue(dlg
.GetNumbers())
499 def OnSend(self
, evt
= None):
500 self
.save
.Enable(self
.send
.GetValue())
501 self
.number
.GetValidator().empty
= not self
.send
.GetValue()
503 def OnSave(self
, evt
= None):
504 self
.send
.Enable(self
.save
.GetValue())
506 def GenerateCurrent(self
, select
= 0):
507 self
.current
.DeleteAllItems()
508 for i
in range(len(self
.entry
['SMSInfo']['Entries'])):
510 x
= self
.entry
['SMSInfo']['Entries'][i
]
513 self
.current
.InsertImageStringItem(i
, p
[1], p
[0])
517 self
.current
.InsertImageStringItem(i
, _('Not supported id: %s') % x
['ID'], -1)
518 print 'Not supported id: %s' % x
['ID']
520 count
= self
.current
.GetItemCount()
523 while select
> count
:
525 self
.current
.SetItemState(select
, wx
.LIST_STATE_FOCUSED | wx
.LIST_STATE_SELECTED
, wx
.LIST_STATE_FOCUSED | wx
.LIST_STATE_SELECTED
)
527 if hasattr(self
, 'editor'):
528 self
.sizer
.Detach(self
.editor
)
529 self
.editor
.Destroy()
531 self
.editor
= wx
.StaticText(self
, -1, _('Create new message by adding part to left list...'), size
= (-1, 150))
532 self
.sizer
.Add(self
.editor
, pos
= (self
.editorrow
,1), flag
= wx
.EXPAND
, span
= wx
.GBSpan(colspan
= 7))
535 def AvailableSelected(self
, event
):
536 self
.availsel
= event
.m_itemIndex
538 def OnUnicode(self
, event
):
539 self
.entry
['SMSInfo']['Unicode'] = self
.unicode.GetValue()
540 if hasattr(self
.editor
, 'OnUnicode'):
541 self
.editor
.OnUnicode(self
.unicode.GetValue())
543 def CurrentSelected(self
, event
):
545 if hasattr(self
, 'editor'):
546 self
.sizer
.Detach(self
.editor
)
547 self
.editor
.Destroy()
552 if self
.entry
['SMSInfo']['Entries'][event
.m_itemIndex
]['ID'] in p
[2]:
553 self
.editor
= p
[3](self
, self
.entry
['SMSInfo']['Entries'][event
.m_itemIndex
], self
.cfg
, self
.unicode.GetValue())
554 self
.sizer
.Add(self
.editor
, pos
= (self
.editorrow
,1), flag
= wx
.EXPAND
, span
= wx
.GBSpan(colspan
= 7))
558 self
.editor
= wx
.StaticText(self
, -1, _('No editor available for type %s') % self
.entry
['SMSInfo']['Entries'][event
.m_itemIndex
]['ID'])
559 self
.sizer
.Add(self
.editor
, pos
= (self
.editorrow
,1), flag
= wx
.EXPAND
, span
= wx
.GBSpan(colspan
= 7))
562 self
.prevedit
= event
.m_itemIndex
565 def UpPressed(self
, evt
):
566 if self
.prevedit
== -1:
568 next
= self
.prevedit
- 1
572 v
= self
.entry
['SMSInfo']['Entries'][self
.prevedit
]
573 self
.entry
['SMSInfo']['Entries'][self
.prevedit
] = self
.entry
['SMSInfo']['Entries'][next
]
574 self
.entry
['SMSInfo']['Entries'][next
] = v
576 self
.GenerateCurrent(next
)
578 def DnPressed(self
, evt
):
579 if self
.prevedit
== -1:
581 next
= self
.prevedit
+ 1
582 if next
>= self
.current
.GetItemCount():
585 v
= self
.entry
['SMSInfo']['Entries'][self
.prevedit
]
586 self
.entry
['SMSInfo']['Entries'][self
.prevedit
] = self
.entry
['SMSInfo']['Entries'][next
]
587 self
.entry
['SMSInfo']['Entries'][next
] = v
589 self
.GenerateCurrent(next
)
591 def DeletePressed(self
, evt
):
592 if self
.prevedit
== -1:
595 del self
.entry
['SMSInfo']['Entries'][self
.prevedit
]
596 next
= self
.prevedit
- 1
598 self
.GenerateCurrent(max(next
, 0))
600 def AddPressed(self
, evt
):
601 if self
.availsel
== -1:
603 v
= {'ID': SMSParts
[self
.availsel
][4]}
604 if v
['ID'][-5:] == '16bit' and self
.cfg
.Read('/Message/16bitId') != 'yes':
605 v
['ID'] = v
['ID'][:-5]
607 self
.entry
['SMSInfo']['Entries'].insert(self
.prevedit
+ 1, v
)
608 next
= self
.prevedit
+ 1
610 self
.GenerateCurrent(next
)
612 def StoreEdited(self
):
613 if self
.prevedit
!= -1:
614 self
.entry
['SMSInfo']['Entries'][self
.prevedit
] = self
.editor
.GetValue()
616 if self
.report
.GetValue():
617 self
.entry
['Type'] = 'Status_Report'
619 self
.entry
['Type'] = 'Submit'
621 if self
.sent
.GetValue():
622 self
.entry
['State'] = 'Sent'
624 self
.entry
['State'] = 'UnSent'
626 if self
.flash
.GetValue():
627 self
.entry
['SMSInfo']['Class'] = 0
629 self
.entry
['SMSInfo']['Class'] = 1
631 self
.entry
['Numbers'] = Wammu
.PhoneValidator
.SplitNumbers(self
.number
.GetValue())
632 self
.entry
['SMSInfo']['Unicode'] = self
.unicode.GetValue()
633 self
.entry
['Save'] = self
.save
.GetValue()
634 self
.entry
['Send'] = self
.send
.GetValue()
635 self
.entry
['Folder'] = self
.folder
.GetValue()
637 def Preview(self
, evt
):
638 if len(self
.entry
['SMSInfo']['Entries']) == 0:
639 dlg
= wx
.MessageDialog(self
, _('Nothing to preview, message is empty.'),
640 _('Message empty!'), wx
.OK | wx
.ICON_WARNING
)
643 msg
= gammu
.EncodeSMS(self
.entry
['SMSInfo'])
644 info
= gammu
.DecodeSMS(msg
)
648 result
['SMSInfo'] = info
649 Wammu
.Utils
.ParseMessage(result
, (info
!= None))
650 dlg
= MessagePreview(self
, ('<i>%s</i><hr>' % (_('Message will fit into %d SMSes') % len(msg
))) + Wammu
.MessageDisplay
.SmsToHtml(self
.cfg
, result
))
656 if not self
.number
.GetValidator().Validate(self
):
661 self
.EndModal(wx
.ID_OK
)