[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r8333 - trunk/gnue-designer/src/uidrivers/wx/uihelpers/documentca
From: |
jcater |
Subject: |
[gnue] r8333 - trunk/gnue-designer/src/uidrivers/wx/uihelpers/documentcanvas |
Date: |
Mon, 3 Apr 2006 18:24:47 -0500 (CDT) |
Author: jcater
Date: 2006-04-01 00:18:29 -0600 (Sat, 01 Apr 2006)
New Revision: 8333
Modified:
trunk/gnue-designer/src/uidrivers/wx/uihelpers/documentcanvas/canvas.py
Log:
implemented a live feedback of moving and resizing with the mouse
Modified:
trunk/gnue-designer/src/uidrivers/wx/uihelpers/documentcanvas/canvas.py
===================================================================
--- trunk/gnue-designer/src/uidrivers/wx/uihelpers/documentcanvas/canvas.py
2006-04-01 04:42:18 UTC (rev 8332)
+++ trunk/gnue-designer/src/uidrivers/wx/uihelpers/documentcanvas/canvas.py
2006-04-01 06:18:29 UTC (rev 8333)
@@ -68,6 +68,7 @@
self.__mouse_current_action = ""
self.__mouse_move_buffer = None
self.__mouse_move_bounds = None
+ self.__hide_selection_frame = False
def __del__(self):
@@ -160,19 +161,18 @@
self.draw_widgets(memoryDC)
# Move the offscreen bitmap onto the scrolled window
- paintDC.Blit(bufferX, bufferY,
- bufferWidth, bufferHeight,
- memoryDC,
- bufferX, bufferY)
+ paintDC.Blit(bufferX, bufferY, bufferWidth, bufferHeight,
+ memoryDC, bufferX, bufferY)
# Draw the mouse move buffer, if applicable
if self.__mouse_move_bounds:
x,y,w,h = self.__mouse_move_bounds.Get()
paintDC.Blit(x, y, w, h, self.__mouse_move_buffer, 0, 0,
- wx.AND, True, 0, 0)
+ wx.AND, True, 0, 0)
memoryDC.EndDrawing()
+
def draw_widgets(self, dc):
"""
Draw the individual widgets
@@ -189,10 +189,9 @@
index = len(self.ordered_widget_list) - 1
-
while index >= 0:
- drawableObject = self.ordered_widget_list [index]
- refresh_bounds = drawableObject.refresh_bounds
+ widget = self.ordered_widget_list [index]
+ refresh_bounds = widget.refresh_bounds
(objectX, objectY,
objectWidth, objectHeight) = refresh_bounds.Get()
@@ -203,20 +202,19 @@
objectWidth, objectHeight)
-
# Keep track of the overall bounds of all the selected
# widgets, so we can draw a selection box later
- if drawableObject.selected:
+ if widget.selected:
if selection_bounds is None:
selection_bounds = bounds
else:
selection_bounds = selection_bounds.Union(bounds)
if (updateRegion.ContainsRect(bounds) != wx.OutRegion and
- drawableObject.visible):
+ widget.visible):
dc.SetDeviceOrigin(objectX + dcOriginX, objectY + dcOriginY)
- drawableObject.draw(dc)
+ widget.draw(dc)
dc.SetDeviceOrigin(dcOriginX, dcOriginY)
index -= 1
@@ -224,9 +222,7 @@
# TODO: Somehow move most of this logic out of draw...
# Draw a box around all the selected widgets
- if selection_bounds is not None:
- self.__mouse_hot_spots = []
- add_hotspot = self.__mouse_hot_spots.append
+ if selection_bounds is not None and not self.__hide_selection_frame:
x, y, w, h = selection_bounds.Get()
@@ -237,42 +233,59 @@
w -= 4
h -= 4
- # TODO: quick fix for enforcing a min size (fix!)
- w = max(w, 17)
- h = max(h, 17)
-
selection_bounds = self.__selection_bounds = wx.Rect(x,y,w,h)
+ self.__draw_selection_box(dc, x,y,w,h)
- # Draw the main border
- dc.SetBrush(wx.Brush(wx.BLACK, wx.TRANSPARENT))
+ else:
+ self.__selection_bounds = None
+
+
+ def __draw_selection_box(self, dc, x, y, w, h, xor=False):
+
+ self.__mouse_hot_spots = []
+ add_hotspot = self.__mouse_hot_spots.append
+
+ # TODO: quick fix for enforcing a min size (fix!)
+ w = max(w, 17)
+ h = max(h, 17)
+
+ # Draw the main border
+ dc.SetBrush(wx.TRANSPARENT_BRUSH)
+ if xor:
+ dc.SetPen(wx.Pen(wx.WHITE, 1, wx.DOT))
+ dc.SetLogicalFunction(wx.XOR)
+ else:
dc.SetPen(wx.Pen(colorIndex['selectionframe']))
- dc.DrawRectangleRect(selection_bounds)
- # Draw the sizer grippers
+ dc.DrawRectangle(x, y, w, h)
+
+ # Draw the sizer grippers
+ if not xor:
dc.SetBrush(wx.Brush(wx.WHITE))
- for bx, by, position in (
- (x - 2, y - 2, 'resize-ul'), # upper left
- (x + w - 3, y - 2, 'resize-ur'), # upper right
- (x - 2, y + h - 3, 'resize-ll'), # lower left
- (x + w - 3, y + h - 3, 'resize-lr'), # lower right
- (x - 2 + w / 2, y - 2, 'resize-top'), # top middle
- (x - 2, y - 2 + h / 2,'resize-left'), # left middle
- (x + w - 3, y - 2 + h / 2, 'resize-right'), # right middle
- (x - 2 + w / 2 , y + h - 3, 'resize-bottom'), # bottom middle
- ):
- rect = wx.Rect(bx,by,5,5)
- dc.DrawRectangleRect(rect)
- add_hotspot((rect,position))
+ for bx, by, position in (
+ (x - 2, y - 2, 'resize-ul'), # upper left
+ (x + w - 3, y - 2, 'resize-ur'), # upper right
+ (x - 2, y + h - 3, 'resize-ll'), # lower left
+ (x + w - 3, y + h - 3, 'resize-lr'), # lower right
+ (x - 2 + w / 2, y - 2, 'resize-top'), # top middle
+ (x - 2, y - 2 + h / 2,'resize-left'), # left middle
+ (x + w - 3, y - 2 + h / 2, 'resize-right'), # right middle
+ (x - 2 + w / 2 , y + h - 3, 'resize-bottom'), # bottom middle
+ ):
- # Add hotspot markers for the selection box
+ rect = wx.Rect(bx,by,5,5)
+ dc.DrawRectangleRect(rect)
+ if not xor:
+ add_hotspot((rect,position))
+
+ # Add hotspot markers for the selection box
+ if not xor:
add_hotspot((wx.Rect(x, y, 1, h), 'resize-left'))
add_hotspot((wx.Rect(x, y, w, 1), 'resize-top'))
add_hotspot((wx.Rect(x + w - 1, y, 1, h), 'resize-right'))
add_hotspot((wx.Rect(x, y + h - 1, w, 1), 'resize-bottom'))
add_hotspot((wx.Rect(x + 1, y + 1, w - 1, h - 1), 'move'))
- else:
- self.__selection_bounds = None
def draw_background(self, dc):
@@ -471,8 +484,8 @@
# Support for visual moving hints
# ---------------------------------------------------------------
def __start_moving(self, x, y):
+ self.CaptureMouse()
self.__mouse_move_items = widgets = self.get_selected_widgets()
- self.CaptureMouse()
bounds = wx.Rect()
for widget in widgets:
widget.selected = False
@@ -545,12 +558,68 @@
def __start_resizing(self, x, y, orientation):
self.__mouse_resize_orientation = orientation
self.CaptureMouse()
+ self.__hide_selection_frame = True
+ self.refresh_scrolled_rect(self.__selection_bounds)
+ self.__mouse_resize_orig_bounds = self.__selection_bounds
+ self.__mouse_resize_last_bounds = None
+ self.__mouse_resize_start_x = x
+ self.__mouse_resize_start_y = y
+ ##self.__update_resizing(x,y)
def __update_resizing(self, x, y):
orientation = self.__mouse_resize_orientation
+ dc = wx.ClientDC(self)
+ dc.BeginDrawing()
+ if self.__mouse_resize_last_bounds:
+ self.__draw_selection_box(dc,
+ *self.__mouse_resize_last_bounds + [True])
+
+ if x is not None:
+ dx = x - self.__mouse_resize_start_x
+ dy = y - self.__mouse_resize_start_y
+
+ ox, oy, ow, oh = self.__mouse_resize_orig_bounds.Get()
+
+ ox2 = ox + ow - 1
+ oy2 = oy + oh - 1
+
+ if orientation == 'left':
+ ox += dx
+ elif orientation == 'right':
+ ox2 += dx
+ elif orientation == 'top':
+ oy += dy
+ elif orientation == 'bottom':
+ oy2 += dy
+ elif orientation == 'ul':
+ ox += dx
+ oy += dy
+ elif orientation == 'ur':
+ ox2 += dx
+ oy += dy
+ elif orientation == 'll':
+ ox += dx
+ oy2 += dy
+ elif orientation == 'lr':
+ ox2 += dx
+ oy2 += dy
+
+ ow = ox2 - ox
+ oh = oy2 - oy
+
+ self.__mouse_resize_last_bounds = last = [ox, oy, ow, oh]
+ self.__draw_selection_box(dc, *last + [True])
+
+
+
+ dc.EndDrawing()
+
def __stop_resizing(self):
self.ReleaseMouse()
+ self.__update_resizing(None, None)
+ self.__hide_selection_frame = False
+ self.refresh_scrolled_rect(self.__mouse_resize_orig_bounds)
# ---------------------------------------------------------------
@@ -613,9 +682,9 @@
if(self.internalDnDItem != None) and(result == wx.DragMove):
assert(self.ordered_widget_list.count(self.internalDnDItem) == 1)
- drawableObject =
self.ConvertDataObjectToDrawableObject(dataObject, x, y, True)
- x = drawableObject.refresh_bounds.GetLeft()
- y = drawableObject.refresh_bounds.GetTop()
+ widget = self.ConvertDataObjectToDrawableObject(dataObject, x,
y, True)
+ x = widget.refresh_bounds.GetLeft()
+ y = widget.refresh_bounds.GetTop()
self.ordered_widget_list.remove(self.internalDnDItem)
self.ordered_widget_list.insert(0, self.internalDnDItem)
@@ -623,12 +692,12 @@
self.internalDnDItem.Show(True)
else:
- drawableObject =
self.ConvertDataObjectToDrawableObject(dataObject, x, y, False)
- x = drawableObject.refresh_bounds.GetLeft()
- y = drawableObject.refresh_bounds.GetTop()
+ widget = self.ConvertDataObjectToDrawableObject(dataObject, x,
y, False)
+ x = widget.refresh_bounds.GetLeft()
+ y = widget.refresh_bounds.GetTop()
- self.ordered_widget_list.insert(0, drawableObject)
- drawableObject.force_canvas_refresh()
+ self.ordered_widget_list.insert(0, widget)
+ widget.force_canvas_refresh()
return result
@@ -641,10 +710,10 @@
Mark all selected objects as not selected. Only Refresh the objects
that change, don't call Update.
"""
- for drawableObject in self.get_selected_widgets():
- if (drawableObject.selected):
- drawableObject.selected = False
- drawableObject.force_canvas_refresh()
+ for widget in self.get_selected_widgets():
+ if (widget.selected):
+ widget.selected = False
+ widget.force_canvas_refresh()
def add(self, widget):
"""
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r8333 - trunk/gnue-designer/src/uidrivers/wx/uihelpers/documentcanvas,
jcater <=