Changeset 352
- Timestamp:
- Wed Oct 24 13:50:12 2007
- Files:
-
- scripts/trunk/ORM/Open ORM Window.py (modified) (diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
scripts/trunk/ORM/Open ORM Window.py
r351 r352 2699 2699 2700 2700 # text = orm_object.Text or 'empty note' 2701 lines = [] 2702 word = orm_object.Name or 'default name' 2701 text = orm_object.Name or 'default name' 2703 2702 if orm_object.Independent: 2704 work+= "!"2703 text += "!" 2704 2703 if orm_object.Derived: 2705 work += orm_object.Derived 2706 lines.append(word) 2704 text += orm_object.Derived 2705 lines = text.splitlines() 2707 2706 word = orm_object.RefMode or '' 2708 2707 if word: … … 2738 2737 dc.SetTextForeground('Black') 2739 2738 dc.SetTextBackground('White') 2740 dc.DrawText(lines[0], x - sizes[0][0]/2, box_y+3) # center text in box 2741 dc.DrawText(lines[1], x - sizes[1][0]/2, box_y+box_h/2+1) 2739 yy = box_y + 3 2740 for i in range(len(lines)): 2741 dc.DrawText(lines[i], x - sizes[i][0]/2, yy) # center text in box 2742 # dc.DrawText(lines[1], x - sizes[1][0]/2, box_y+box_h/2+1) 2743 yy += sizes[i][1] 2742 2744 2743 2745 r = wx.Rect(box_x,box_y,box_w,box_h) … … 2748 2750 if debug: print "char", ord(char), "'", char, "'" 2749 2751 orm_object = self.Get('Target') 2750 orm_object.Name += char 2752 if orm_object.Name: 2753 if char == '\x08': # this is for windows, cross platform? 2754 orm_object.Name = orm_object.Name[:-1] 2755 elif char == '\r': # this is for windows, cross platform? 2756 orm_object.Name += '\n' 2757 else: 2758 orm_object.Name += char 2759 else: 2760 if char in '\r\x08': # this is for windows, cross platform? 2761 pass 2762 else: 2763 orm_object.Name = char 2751 2764 2752 2765 class ORMFactShape(ORMBox): … … 2758 2771 ## y = self.PosY 2759 2772 2773 prior_r = self.canvas.pdc.GetIdBounds(self.dcid) 2774 if debug: print "prior rectangle", prior_r 2760 2775 dc.ClearId(self.dcid) 2761 2776 dc.SetId(self.dcid) … … 2780 2795 dc.SetIdBounds(self.dcid,r) 2781 2796 2797 r = self.canvas.pdc.GetIdBounds(self.dcid) 2798 if debug: print "new rectangle", r 2799 2800 ## def Char(self, char): # should change the reading -- CHANGE! 2801 ## if debug: print "char", ord(char), "'", char, "'" 2802 ## orm_object = self.Get('Target') 2803 ## if orm_object.Name: 2804 ## if char == '\x08': # this is for windows, cross platform? 2805 ## orm_object.Name = orm_object.Name[:-1] 2806 ## elif char == '\r': # this is for windows, cross platform? 2807 ## orm_object.Name += '\n' 2808 ## else: 2809 ## orm_object.Name += char 2810 ## else: 2811 ## if char in '\r\x08': # this is for windows, cross platform? 2812 ## pass 2813 ## else: 2814 ## orm_object.Name = char 2815 2782 2816 class ORMNoteShape(ORMBox): 2783 2817 def Draw(self, dc): … … 3262 3296 shape._SetToSubclass(ORMObjectShape) 3263 3297 shape.SetTempPos(x,y) # used to avoid lots of updates while moving 3264 # shape._SetInShell('Draw', DrawORMObject)3265 print dir(shape)3266 print shape.__class__3267 3298 shape.Draw(dc) 3268 3299 … … 3270 3301 shape._SetToSubclass(ORMFactShape) 3271 3302 shape.SetTempPos(x,y) # used to avoid lots of updates while moving 3272 # shape._SetInShell('Draw', DrawORMObject)3273 print dir(shape)3274 print shape.__class__3275 3303 shape.Draw(dc) 3276 3304 … … 3278 3306 shape._SetToSubclass(ORMNoteShape) 3279 3307 shape.SetTempPos(x,y) # used to avoid lots of updates while moving 3280 # shape._SetInShell('Draw', DrawORMObject)3281 print dir(shape)3282 print shape.__class__3283 3308 shape.Draw(dc) 3284 3309 … … 3286 3311 shape._SetToSubclass(ORMConstraintShape) 3287 3312 shape.SetTempPos(x,y) # used to avoid lots of updates while moving 3288 # shape._SetInShell('Draw', DrawORMObject)3289 print dir(shape)3290 print shape.__class__3291 3313 shape.Draw(dc) 3292 3314 … … 3294 3316 shape._SetToSubclass(ORMConstraintConnectorShape) 3295 3317 shape.SetTempPos(x,y) # used to avoid lots of updates while moving 3296 print dir(shape)3297 print shape.__class__3298 3318 shape.Follow() 3299 3319 shape.Draw(dc) … … 3302 3322 shape._SetToSubclass(ORMRoleShape) 3303 3323 shape.SetTempPos(x,y) # used to avoid lots of updates while moving 3304 # shape._SetInShell('Draw', DrawORMObject)3305 print dir(shape)3306 print shape.__class__3307 3324 shape.Follow() 3308 3325 shape.Draw(dc) … … 3311 3328 shape._SetToSubclass(ORMNoteConnectorShape) 3312 3329 shape.SetTempPos(x,y) # used to avoid lots of updates while moving 3313 # shape._SetInShell('Draw', DrawORMObject)3314 print dir(shape)3315 print shape.__class__3316 3330 shape.Follow() 3317 3331 shape.Draw(dc) … … 3325 3339 self.RefreshRect(r, False) 3326 3340 3341 def RedrawID(self, id): 3342 r = self.pdc.GetIdBounds(id) 3343 shape = self.dcid_to_shape_xref.get(id) 3344 shape.Draw(self.pdc) 3345 r2 = self.pdc.GetIdBounds(id) 3346 r = r.Union(r2) 3347 r.Inflate(4,4) 3348 self.OffsetRect(r) # is this needed? what does it do? 3349 self.RefreshRect(r, False) 3350 3327 3351 def ConnectEm(self, source, target): 3328 3352 if debug: print 'connecting', source.TableName, target.TableName … … 3356 3380 if event.LeftDown(): # select object -> object potentially source of arrow 3357 3381 x,y = self.ConvertEventCoords(event) 3358 #l = self.pdc.FindObjectsByBBox(x, y)3359 3382 l = self.pdc.FindObjects(x, y, hitradius) 3360 3361 # keyboard input 3362 self.selection_dcid = l 3363 # self.SetFocusEnable() # this didn't work 3364 self.SetFocus() 3365 3366 if l: 3383 if l: # select existing object 3367 3384 for id in l: 3368 3385 if not self.pdc.GetIdGreyedOut(id): … … 3379 3396 self.RedisplayID(new_shape.dcid) 3380 3397 # make object current selection 3381 self.dragid = id # remember start of drag 3398 self.dragid = new_shape.dcid # remember start of drag 3381 3398 self.lastpos = (event.GetX(),event.GetY()) # needed? 3399 l = [new_shape.dcid] 3400 3401 # keyboard input 3402 self.selection_dcid = l 3403 # self.SetFocusEnable() # this didn't work 3404 self.SetFocus() 3405 3382 3406 elif event.RightDown(): 3383 3407 x,y = self.ConvertEventCoords(event) … … 3398 3422 if self.dragid != -1: 3399 3423 pass 3400 ## x,y = self.lastpos3401 ## dx = event.GetX() - x3402 ## dy = event.GetY() - y3403 ## r = self.pdc.GetIdBounds(self.dragid)3404 ## self.pdc.TranslateId(self.dragid, dx, dy)3405 ## r2 = self.pdc.GetIdBounds(self.dragid)3406 ## r = r.Union(r2)3407 ## r.Inflate(4,4)3408 ## self.OffsetRect(r)3409 ## self.RefreshRect(r, False)3410 ## self.lastpos = (event.GetX(),event.GetY())3411 3424 if event.LeftUp(): 3412 3425 # self.dragid = -1 … … 3420 3433 self.ConnectEm(source, target) 3421 3434 else: # create target object and connection (if legal) 3422 pass 3423 ## # add new object 3424 ## ll = self.AddNode(self.leftClickType, x, y) 3425 ## Data.SetUndo('Add %s' % self.leftClickType) 3426 ## # redisplay object?? 3435 source = self.dcid_to_shape_xref.get(self.dragid) 3436 if debug: print "source class:", source.__class__ 3437 target = None 3438 if isinstance(source, ORMObjectShape): 3439 target = self.AddNode('ORMFact', x, y) 3440 elif isinstance(source, ORMFactShape): 3441 target = self.AddNode('ORMObject', x, y) 3442 if not target is None: 3443 Data.SetUndo('Add %s' % target.__class__) 3444 self.RedisplayID(target.dcid) 3445 self.ConnectEm(source, target) 3446 self.RedrawID(source.dcid) # better way to do? 3447 self.RedrawID(target.dcid) 3448 pass 3427 3449 ## r = self.pdc.GetIdBounds(self.shapeid_to_dcid_xref[ll]) 3428 3450 ## r.Inflate(4,4) … … 3513 3535 if debug: print "char -", unichr(evt.GetUnicodeKey()), "-" 3514 3536 if self.selection_dcid: 3515 shape = self.dcid_to_shape_xref.get(self.selection_dcid) 3537 shape = self.dcid_to_shape_xref.get(self.selection_dcid[0]) 3515 3537 shape.Char(unichr(evt.GetUnicodeKey())) 3538 ## shape.Draw(self.pdc) 3539 ## self.RedisplayID(shape.dcid) 3540 self.RedrawID(shape.dcid) 3516 3541 # evt.Skip() # don't know if I should skip them or not 3517 3542
