Mercurial > fife-parpg
diff engine/extensions/pychan/internal.py @ 255:51cc05d862f2
Merged editor_rewrite branch to trunk.
This contains changes that may break compatibility against existing clients.
For a list of changes that may affect your client, see: http://wiki.fifengine.de/Changes_to_pychan_and_FIFE_in_editor_rewrite_branch
author | cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Mon, 08 Jun 2009 16:00:02 +0000 |
parents | 756b895e1dab |
children | 48c99636453e |
line wrap: on
line diff
--- a/engine/extensions/pychan/internal.py Wed Jun 03 19:29:52 2009 +0000 +++ b/engine/extensions/pychan/internal.py Mon Jun 08 16:00:02 2009 +0000 @@ -2,6 +2,7 @@ from compat import guichan, in_fife import widgets +import fife_timer as timer import fonts from exceptions import * from traceback import print_exc @@ -24,10 +25,11 @@ class Manager(object): manager = None - def __init__(self, hook, debug = False): + def __init__(self, hook, debug = False, compat_layout = False): super(Manager,self).__init__() self.hook = hook self.debug = debug + self.compat_layout = compat_layout self.unicodePolicy = ('ignore',) if in_fife: @@ -35,6 +37,7 @@ raise InitializationError("No event manager installed.") if not hook.engine.getGuiManager(): raise InitializationError("No GUI manager installed.") + timer.init(hook.engine.getTimeManager()) self.fonts = {} #glyphs = ' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,!?-+/:();%`\'*#=[]"' @@ -43,13 +46,16 @@ self.styles = {} self.addStyle('default',DEFAULT_STYLE) - Manager.manager = self + Manager.manager = self # Setup synchronous dialogs self.mainLoop = None self.breakFromMainLoop = None self.can_execute = False + import weakref + self.allWidgets = weakref.WeakKeyDictionary() + # Autopos from autoposition import placeWidget self.placeWidget = placeWidget @@ -67,6 +73,8 @@ Shows a widget on screen. Used by L{Widget.show} - do not use directly. """ self.placeWidget(widget, widget.position_technique) + assert widget not in self.allWidgets + self.allWidgets[ widget ] = 1 self.hook.add_widget( widget.real_widget ) def hide(self,widget): @@ -74,6 +82,7 @@ Hides a widget again. Used by L{Widget.hide} - do not use directly. """ self.hook.remove_widget( widget.real_widget ) + del self.allWidgets[ widget ] def setDefaultFont(self,name): self.fonts['default'] = self.getFont(name) @@ -133,6 +142,9 @@ setattr(widget,k,v) def _remapStyleKeys(self,style): + """ + Translate style selectors to tuples of widget classes. (internal) + """ # Remap class names, create copy: def _toClass(class_): if class_ == "default": @@ -168,6 +180,7 @@ 'foreground_color' : guichan.Color(255,255,255), 'background_color' : guichan.Color(50,50,50), 'selection_color' : guichan.Color(80,80,80), + 'font' : 'default' }, 'Button' : { 'border_size': 2, @@ -183,6 +196,7 @@ }, 'Label' : { 'border_size': 0, + 'background_color' : guichan.Color(50,50,50,0) }, 'ClickLabel' : { 'border_size': 0, @@ -194,10 +208,9 @@ 'border_size': 0, 'margins': (5,5), 'opaque' : 1, + 'padding':2, 'titlebar_height' : 12, - 'vexpanding' : 1, - #'background_image' : 'gui/backgrounds/background.png', - #'font' : 'samanata_large' + 'background_image' : None, }, 'TextBox' : { }, @@ -205,6 +218,7 @@ 'border_size': 0, 'margins': (0,0), 'padding':2, - #'background_image' : 'gui/backgrounds/background.png', + 'opaque' : 1, + 'background_image' : None, } } \ No newline at end of file