Package muntjac :: Package addon :: Package csstools :: Module render_info
[hide private]
[frames] | no frames]

Source Code for Module muntjac.addon.csstools.render_info

1 # Copyright (C) 2012 Vaadin Ltd. 2 # Copyright (C) 2012 Richard Lincoln 3 # 4 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # you may not use this file except in compliance with the License. 6 # You may obtain a copy of the License at 7 # 8 # http://www.apache.org/licenses/LICENSE-2.0 9 # 10 # Unless required by applicable law or agreed to in writing, software 11 # distributed under the License is distributed on an "AS IS" BASIS, 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 # See the License for the specific language governing permissions and 14 # limitations under the License. 15 16 17 -class RenderInfo(object):
18 """Class for fetching render information from the client side widgets. 19 20 @author: jouni@vaadin.com 21 @author: Richard Lincoln 22 """ 23 24 @classmethod
25 - def get(cls, c, cb, *props):
26 """Initiate a request to get the render information for a given component. 27 28 The information can be for example the exact pixel size and position, the 29 font size, visibility, margin, padding or border of the component in the 30 browser. See possible values from the {@link CssProperty} enumerable. 31 32 The information will be delivered asynchronously from the client, and 33 passed as a parameter to the callback method. 34 35 You can limit the amount of properties transmitted over the connection by 36 passing the desired property names as the last parameter for the method. 37 38 @param c: 39 The component whose render information you wish to get. 40 @param cb: 41 The callback object which will receive the information when it 42 is available. 43 @param props: 44 Optional. The list of CSS properties you wish to get from the 45 client (limit the amount of transferred data). You can pass 46 any type of objects here, the C{__str__()} method 47 will be used to convert them to actual property names. 48 Preferably use the L{CssProperty} enumerable for feasible values. 49 """ 50 if c.getApplication() is None: 51 raise ValueError('The component must be attached to the application before you try to get it\'s RenderInfo') 52 53 from muntjac.addon.csstools.render_info_fetcher \ 54 import RenderInfoFetcher 55 56 fetcher = RenderInfoFetcher(c, cb, *props) 57 c.getApplication().getMainWindow().addWindow(fetcher)
58 59
60 - def __init__(self, obj):
61 self._props = obj
62 63
64 - def getProperty(self, prop):
65 return self._props[str(prop)]
66
67 68 -class ICallback(object):
69 """The callback interface for RenderInformation requests. 70 71 @author: jouni@vaadin.com 72 @author: Richard Lincoln 73 """ 74
75 - def infoReceived(self, info):
76 """This method is called when a RenderInfo request is returned from the 77 client and the RenderInfo for that request is available. 78 79 @param info: 80 The RenderInfo object for the request, containing the 81 requested properties (or all possible properties if no 82 specific properties were requested). 83 """ 84 raise NotImplementedError
85