Changeset 1620
- Timestamp:
- 07/11/07 14:22:15 (1 year ago)
- Files:
-
- gaphas/branches/hw/gaphas/item.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
gaphas/branches/hw/gaphas/item.py
r1618 r1620 239 239 self._handles = [ h(strength=VERY_STRONG) for h in [Handle]*4 ] 240 240 self._constraints = [] 241 self._min_width = 10 242 self._min_height = 10 241 242 # create minimal size constraints 243 handles = self._handles 244 h_nw = handles[NW] 245 h_se = handles[SE] 246 self._c_min_w = LessThanConstraint(smaller=h_nw.y, bigger=h_se.y, delta=10) 247 self._c_min_h = LessThanConstraint(smaller=h_nw.x, bigger=h_se.x, delta=10) 248 249 # set width/height when minimal size constraints exist 243 250 self.width = width 244 251 self.height = height 252 245 253 246 254 def _set_width(self, width): … … 301 309 def _set_min_width(self, min_width): 302 310 """ 303 """ 304 self._min_width = max(0, min_width) 311 Set minimal width. 312 """ 313 if min_width < 0: 314 raise ValueError, 'Minimal width cannot be less than 0' 315 316 self._c_min_w.delta = min_width 317 305 318 if min_width > self.width: 306 319 self.width = min_width 307 320 308 min_width = reversible_property(lambda s: s._ min_width, _set_min_width)321 min_width = reversible_property(lambda s: s._c_min_w.delta, _set_min_width) 309 322 310 323 @observed 311 324 def _set_min_height(self, min_height): 312 325 """ 313 """ 314 self._min_height = max(0, min_height) 326 Set minimal height. 327 """ 328 if min_height < 0: 329 raise ValueError, 'Minimal height cannot be less than 0' 330 331 self._c_min_h.delta = min_height 332 315 333 if min_height > self.height: 316 334 self.height = min_height 317 335 318 min_height = reversible_property(lambda s: s._ min_height, _set_min_height)336 min_height = reversible_property(lambda s: s._c_min_h.delta, _set_min_height) 319 337 320 338 def setup_canvas(self): … … 361 379 add(eq(a=h_se.y, b=h_sw.y)), 362 380 add(eq(a=h_se.x, b=h_ne.x)), 363 # set h_nw < h_se constraint 381 # set h_nw < h_se constraints 364 382 # with minimal size functionality 365 add( lt(smaller=h_nw.y, bigger=h_se.y, delta=10)),366 add( lt(smaller=h_nw.x, bigger=h_se.x, delta=10)),383 add(self._c_min_w), 384 add(self._c_min_h), 367 385 ] 368 386
