comparison browser_side/panels.py @ 186:72bb1d845b6a

browser side: global resize on UniBox resize
author Goffi <goffi@goffi.org>
date Sun, 03 Mar 2013 04:27:39 +0100
parents 40adfd4ee4d7
children d0503f8f15ef
comparison
equal deleted inserted replaced
185:40adfd4ee4d7 186:72bb1d845b6a
36 from pyjamas.ui.HTML import HTML 36 from pyjamas.ui.HTML import HTML
37 from pyjamas.ui.Image import Image 37 from pyjamas.ui.Image import Image
38 from pyjamas.ui.DropWidget import DropWidget 38 from pyjamas.ui.DropWidget import DropWidget
39 from pyjamas.ui.ClickListener import ClickHandler 39 from pyjamas.ui.ClickListener import ClickHandler
40 from pyjamas.ui.KeyboardListener import KEY_ENTER 40 from pyjamas.ui.KeyboardListener import KEY_ENTER
41 from pyjamas.ui.MouseListener import MouseHandler
41 from pyjamas.ui import HasAlignment 42 from pyjamas.ui import HasAlignment
42 from pyjamas.Timer import Timer 43 from pyjamas.Timer import Timer
43 from pyjamas import Window 44 from pyjamas import Window
44 from pyjamas import DOM 45 from pyjamas import DOM
45 from card_game import CardPanel 46 from card_game import CardPanel
366 self.setStyleName('uniBoxPanel') 367 self.setStyleName('uniBoxPanel')
367 self.unibox = UniBox(host) 368 self.unibox = UniBox(host)
368 self.unibox.setWidth('100%') 369 self.unibox.setWidth('100%')
369 self.add(self.unibox) 370 self.add(self.unibox)
370 371
371 class UniBox(TextArea): #AutoCompleteTextBox): 372 class UniBox(TextArea, MouseHandler): #AutoCompleteTextBox):
372 """This text box is used as a main typing point, for message, microblog, etc""" 373 """This text box is used as a main typing point, for message, microblog, etc"""
373 374
374 def __init__(self, host): 375 def __init__(self, host):
375 TextArea.__init__(self) 376 TextArea.__init__(self)
376 #AutoCompleteTextBox.__init__(self) 377 #AutoCompleteTextBox.__init__(self)
378 self.__size = (0,0)
377 self._popup = None 379 self._popup = None
378 self._timer = Timer(notify=self._timeCb) 380 self._timer = Timer(notify=self._timeCb)
379 self.host = host 381 self.host = host
380 self.setStyleName('uniBox') 382 self.setStyleName('uniBox')
381 self.addKeyboardListener(self) 383 self.addKeyboardListener(self)
384 MouseHandler.__init__(self)
385 self.addMouseListener(self)
386
382 387
383 def addKey(self, key): 388 def addKey(self, key):
384 return 389 return
385 #self.getCompletionItems().completions.append(key) 390 #self.getCompletionItems().completions.append(key)
386 391
486 mess_type = "groupchat" if _chat.type=='group' else "chat" 491 mess_type = "groupchat" if _chat.type=='group' else "chat"
487 self.host.bridge.call('sendMessage', None, str(_chat.target), _txt, '', mess_type) 492 self.host.bridge.call('sendMessage', None, str(_chat.target), _txt, '', mess_type)
488 self.setText('') 493 self.setText('')
489 self._timeCb(None) #we remove the popup 494 self._timeCb(None) #we remove the popup
490 sender.cancelKey() 495 sender.cancelKey()
496
497 def onMouseUp(self, sender, x, y):
498 size = (self.getOffsetWidth(), self.getOffsetHeight())
499 if size != self.__size:
500 self.__size = size
501 self.host.resize()
491 502
492 """def complete(self): 503 """def complete(self):
493 504
494 #self.visible=False #XXX: self.visible is not unset in pyjamas when ENTER is pressed and a completion is done 505 #self.visible=False #XXX: self.visible is not unset in pyjamas when ENTER is pressed and a completion is done
495 #XXX: fixed directly on pyjamas, if the patch is accepted, no need to walk around this 506 #XXX: fixed directly on pyjamas, if the patch is accepted, no need to walk around this