Adapt to the new hippo canvas sizing API

This commit is contained in:
Marco Pesenti Gritti 2007-03-14 03:19:24 +01:00
parent 9d8fa7d42a
commit 4960ddae25
4 changed files with 14 additions and 24 deletions

View File

@ -32,7 +32,9 @@ class FramePopupContext(PopupContext):
def get_position(self, control, popup):
[item_x, item_y] = control.get_context().translate_to_screen(control)
[item_w, item_h] = control.get_allocation()
[popup_w, popup_h] = popup.get_request()
[popup_w, natural_w] = popup.get_width_request()
[popup_h, natural_h] = popup.get_height_request(popup_w)
left_x = item_x + item_w
left_y = item_y

View File

@ -327,11 +327,11 @@ class CanvasIcon(hippo.CanvasBox, hippo.CanvasItem):
def do_get_content_width_request(self):
[width, height] = self._get_icon_size()
return width
return (width, width)
def do_get_content_height_request(self, for_width):
[width, height] = self._get_icon_size()
return height
return (height, height)
def do_button_press_event(self, event):
self.emit_activated()
@ -373,8 +373,8 @@ class CanvasIcon(hippo.CanvasBox, hippo.CanvasItem):
[x, y] = context.translate_to_screen(self)
# TODO: Any better place to do this?
popup.props.box_width = max(popup.get_width_request(),
self.get_width_request())
[min_width, natural_width] = self.get_width_request()
popup.props.box_width = max(popup.get_width_request(), min_width)
[width, height] = self.get_allocation()
y += height

View File

@ -104,16 +104,6 @@ class OptionMenu(hippo.CanvasBox, hippo.CanvasItem):
self._menu.add_item(menu_item)
def do_get_width_request(self):
max_width = max(self._canvas_text.do_get_content_width_request(self._canvas_text),
self._menu.do_get_content_width_request(self._menu))
self._canvas_text.props.box_width = max_width
current_width = hippo.CanvasBox.do_get_width_request(self)
self._menu.props.box_width = current_width
return current_width
def add_separator(self):
self._menu.add_separator()

View File

@ -72,17 +72,15 @@ class SnowflakeBox(hippo.CanvasBox, hippo.CanvasItem):
max_child_size = 0
for child in self.get_children():
width = child.get_width_request()
height = child.get_height_request(width)
max_child_size = max (max_child_size, width)
max_child_size = max (max_child_size, height)
[min_w, natural_w] = child.get_width_request()
[min_h, natural_h] = child.get_height_request(width)
max_child_size = max (max_child_size, min_w)
max_child_size = max (max_child_size, min_h)
return self._get_radius() * 2 + \
max_child_size + _FLAKE_DISTANCE * 2
width = self._get_radius() * 2 + \
max_child_size + _FLAKE_DISTANCE * 2
def do_get_height_request(self, width):
hippo.CanvasBox.do_get_height_request(self, width)
return width
return [width, width]
def do_allocate(self, width, height, origin_changed):
hippo.CanvasBox.do_allocate(self, width, height, origin_changed)