Package muntjac :: Package terminal :: Module sizeable
[hide private]
[frames] | no frames]

Source Code for Module muntjac.terminal.sizeable

  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  """Defines an interface to be implemented by components wishing to display 
 17  some object that may be dynamically resized.""" 
 18   
 19   
20 -class ISizeable(object):
21 """Interface to be implemented by components wishing to display some 22 object that may be dynamically resized during runtime. 23 24 @author: Vaadin Ltd. 25 @author: Richard Lincoln 26 @version: 1.1.2 27 """ 28 29 #: Unit code representing pixels. 30 UNITS_PIXELS = 0 31 32 #: Unit code representing points (1/72nd of an inch). 33 UNITS_POINTS = 1 34 35 #: Unit code representing picas (12 points). 36 UNITS_PICAS = 2 37 38 #: Unit code representing the font-size of the relevant font. 39 UNITS_EM = 3 40 41 #: Unit code representing the x-height of the relevant font. 42 UNITS_EX = 4 43 44 #: Unit code representing millimeters. 45 UNITS_MM = 5 46 47 #: Unit code representing centimeters. 48 UNITS_CM = 6 49 50 #: Unit code representing inches. 51 UNITS_INCH = 7 52 53 #: Unit code representing in percentage of the containing element 54 # defined by terminal. 55 UNITS_PERCENTAGE = 8 56 57 SIZE_UNDEFINED = -1 58 59 # Textual representations of units symbols. Supported units and 60 # their symbols are: 61 # 62 # - L{#UNITS_PIXELS}: "px" 63 # - L{#UNITS_POINTS}: "pt" 64 # - L{#UNITS_PICAS}: "pc" 65 # - L{#UNITS_EM}: "em" 66 # - L{#UNITS_EX}: "ex" 67 # - L{#UNITS_MM}: "mm" 68 # - L{#UNITS_CM}. "cm" 69 # - L{#UNITS_INCH}: "in" 70 # - L{#UNITS_PERCENTAGE}: "%" 71 # 72 # These can be used like C{ISizeable.UNIT_SYMBOLS[UNITS_PIXELS]}. 73 UNIT_SYMBOLS = ['px', 'pt', 'pc', 'em', 'ex', 'mm', 'cm', 'in', '%'] 74 75
76 - def getWidth(self):
77 """Gets the width of the object. Negative number implies unspecified 78 size (terminal is free to set the size). 79 80 @return: width of the object in units specified by widthUnits property. 81 """ 82 raise NotImplementedError
83 84
85 - def setWidth(self, *args):
86 """Sets the width of the object. Negative number implies unspecified 87 size (terminal is free to set the size). 88 89 @param args: tuple of the form 90 - (width) 91 1. the width of the object in units specified by widthUnits 92 propertyor in CSS style string representation, null or 93 empty string to reset 94 - (width, unit) 95 1. the width of the object. 96 2. the unit used for the width. Possible values include 97 L{UNITS_PIXELS}, L{UNITS_POINTS}, 98 L{UNITS_PICAS}, L{UNITS_EM}, L{UNITS_EX}, 99 L{UNITS_MM}, L{UNITS_CM}, L{UNITS_INCH}, 100 L{UNITS_PERCENTAGE}. 101 102 See U{CSS specification 103 <http://www.w3.org/TR/REC-CSS2/syndata.html#value-def-length>} for 104 more details. 105 """ 106 raise NotImplementedError
107 108
109 - def getHeight(self):
110 """Gets the height of the object. Negative number implies unspecified 111 size (terminal is free to set the size). 112 113 @return: height of the object in units specified by heightUnits 114 property. 115 """ 116 raise NotImplementedError
117 118
119 - def setHeight(self, *args):
120 """Sets the height of the object. Negative number implies unspecified 121 size (terminal is free to set the size). 122 123 @param args: tuple of the form 124 - (height) 125 1. the height of the object in units specified by 126 heightUnits property or the height of the component using 127 string presentation. String presentation is similar to 128 what is used in Cascading Style Sheets. Size can be 129 length or percentage of available size. 130 - (height, unit) 131 1. the height of the object. 132 2. the unit used for the width. Possible values include 133 L{UNITS_PIXELS}, L{UNITS_POINTS}, 134 L{UNITS_PICAS}, L{UNITS_EM}, L{UNITS_EX}, 135 L{UNITS_MM}, L{UNITS_CM}, L{UNITS_INCH}, 136 L{UNITS_PERCENTAGE}. 137 """ 138 raise NotImplementedError
139 140
141 - def getWidthUnits(self):
142 """Gets the width property units. 143 144 @return: units used in width property. 145 """ 146 raise NotImplementedError
147 148
149 - def setWidthUnits(self, units):
150 """Sets the width property units. 151 152 @param units: 153 the units used in width property. 154 @deprecated: Consider setting width and unit simultaneously using 155 L{setWidth}, which is less error-prone. 156 """ 157 raise NotImplementedError
158 159
160 - def getHeightUnits(self):
161 """Gets the height property units. 162 163 @return: units used in height property. 164 """ 165 raise NotImplementedError
166 167
168 - def setHeightUnits(self, units):
169 """Sets the height property units. 170 171 @param units: 172 the units used in height property. 173 @deprecated: Consider setting height and unit simultaneously using 174 L{setHeight} or which is less error-prone. 175 """ 176 raise NotImplementedError
177 178
179 - def setSizeFull(self):
180 """Sets the size to 100% x 100%.""" 181 raise NotImplementedError
182 183
184 - def setSizeUndefined(self):
185 """Clears any size settings.""" 186 raise NotImplementedError
187