Changeset 451

Show
Ignore:
Timestamp:
Tue Jun 17 17:30:24 2008
Author:
Alexander
Message:

fixed bug where role names moved twice as much; added pencil cursor

Files:

Legend:

Unmodified
Added
Removed
Modified
  • ganttpv/trunk/ORM.py

    r447 r451  
    62 62 # 080606 - Brian - display constraint symbols, connect correctly to adjacent pairs of roles  
    63 63 # 080606 - Alex - deontic constraints; three-way role constraints; shift-click on constraint to add role sequence; new icons  
      64 # 080617 - Alex - fixed bug where role names moved twice as much; added pencil cursor  
    64 65  
    65 66 import wx  
     
    2642 2643         dc.ClearId(self.dcid)  
    2643 2644         if not orm_object: return  # object has probably been undone  
    2644   ##        dc.SetId(self.dcid)  
    2645   ##  
    2646   ##        x, y = self.GetPos()  
    2647   ##  
    2648   ##        text = (orm_object.Name or '')  
    2649   ##        if text: text = '[' + text + ']'  
    2650   ##        if debug: print orm_object, 'has name:', text or '--'  
    2651   ##        lines = text.splitlines()  
    2652   ##        sizes = [ self.canvas.GetFullTextExtent(line)[0:2] for line in lines ]  # pull out only w and h  
    2653   ##        w = 5  
    2654   ##        h = 0  
    2655   ##        for line_w,line_h in sizes:  
    2656   ##            w = max(w, line_w)  
    2657   ##            h += line_h  
    2658   ##        box_w = w + 6  
    2659   ##        box_h = h + 6  
    2660   ##        box_x = x - box_w/2  
    2661   ##        box_y = y - box_h/2  
    2662   ##  
    2663   ##### don't draw anything  
    2664   ##        if text == '':  
    2665   ##            pen = self.canvas.CachedPen(1, 1, wx.DOT)  
    2666   ###            pen = self.canvas.CachedPen(1, 1, wx.SOLID)  
    2667   ##        else:  
    2668   ##            pen = self.canvas.CachedPen(2, 1, wx.SOLID)  
    2669   ##        dc.SetPen(pen)  
    2670   #####            dc.SetBrush(self.RandomBrush())  
    2671   ##        if self.GetSelected():  
    2672   ##            dc.SetBrush(self.canvas.CachedBrush((210,210,210)))  
    2673   ##        else:  
    2674   ##            dc.SetBrush(self.canvas.CachedBrush((254,254,254)))  
    2675   ###        dc.SetBrush(self.canvas.CachedBrush('White'))  
    2676   ##        dc.DrawRectangle(box_x,box_y,box_w,box_h)  
    2677   ##  
    2678   ##        dc.SetFont(self.canvas.GetFont())  
    2679   ###            dc.SetTextForeground(self.RandomColor())  
    2680   ##        dc.SetTextForeground('Black')  
    2681   ##        dc.SetTextBackground('White')  
    2682   ##        w = 3; h = 2  
    2683   ##        for i in range(len(lines)):  
    2684   ##            line = lines[i]  
    2685   ##            line_w, line_h = sizes[i]  
    2686   ##            dc.DrawText(line, box_x+w, box_y+h)  
    2687   ##            h += line_h  
    2688   ##  
    2689   ##        r = wx.Rect(box_x,box_y,box_w,box_h)  
    2690   ##        r.Inflate(pen.GetWidth(),pen.GetWidth())  
    2691   ##        dc.SetIdBounds(self.dcid,r)  
      2645         dc.SetId(self.dcid)  
      2646  
      2647         x, y = self.GetPos()  
      2648  
      2649         text = (orm_object.Name or '')  
      2650         if text: text = '[' + text + ']'  
      2651         if debug: print orm_object, 'has name:', text or '--'  
      2652         lines = text.splitlines()  
      2653         sizes = [ self.canvas.GetFullTextExtent(line)[0:2] for line in lines ]  # pull out only w and h  
      2654         w = 5  
      2655         h = 0  
      2656         for line_w,line_h in sizes:  
      2657             w = max(w, line_w)  
      2658             h += line_h  
      2659         box_w = w + 6  
      2660         box_h = h + 6  
      2661         box_x = x - box_w/2  
      2662         box_y = y - box_h/2  
      2663  
      2664         if text == '':  
      2665             pen = self.canvas.CachedPen(1, 1, wx.DOT)  
      2666         else:  
      2667             pen = self.canvas.CachedPen(2, 1, wx.SOLID)  
      2668         dc.SetPen(pen)  
      2669         if self.GetSelected():  
      2670             dc.SetBrush(self.canvas.CachedBrush((210,210,210)))  
      2671         else:  
      2672             dc.SetBrush(self.canvas.CachedBrush((254,254,254)))  
      2673         dc.DrawRectangle(box_x,box_y,box_w,box_h)  
      2674  
      2675         dc.SetFont(self.canvas.GetFont())  
      2676         dc.SetTextForeground('Black')  
      2677         dc.SetTextBackground('White')  
      2678         w = 3; h = 2  
      2679         for i in range(len(lines)):  
      2680             line = lines[i]  
      2681             line_w, line_h = sizes[i]  
      2682             dc.DrawText(line, box_x+w, box_y+h)  
      2683             h += line_h  
      2684  
      2685         r = wx.Rect(box_x,box_y,box_w,box_h)  
      2686         r.Inflate(pen.GetWidth(),pen.GetWidth())  
      2687         dc.SetIdBounds(self.dcid,r)  
    2692 2688  
    2693 2689     def Char(self, char):  
     
    3321 3317         self.log.write('Created PseudoDC draw list with %d operations!'%self.pdc.GetLen())  
    3322 3318  
      3319         self.keyboard_target_dcid = None  
      3320  
    3323 3321         self.Bind(wx.EVT_PAINT, self.OnPaint)  
    3324 3322         self.Bind(wx.EVT_ERASE_BACKGROUND, lambda x:None)  
     
    3331 3329         self.lastpos = (0,0)  
    3332 3330  
    3333           # wxCURSOR_ARROW  
    3334           # wxCURSOR_PENCIL  
    3335           # wxCURSOR_PAINT_BRUSH  
    3336           # self.SetCursor(wx.StockCursor(wx.CURSOR_PENCIL))  
    3337        
      3331         self.pointer_cursor = wx.StockCursor(wx.CURSOR_ARROW) # wx.Cursor(Menu.IconPath("icons/pointer.bmp"), wx.BITMAP_TYPE_ANY, 5, 0)  
      3332         self.pencil_cursor = wx.Cursor(Menu.IconPath("icons/Pencil.bmp"), wx.BITMAP_TYPE_ANY, 4, 15)  
      3333         wx.EVT_KEY_DOWN(self, self.OnShiftKey)  
      3334         wx.EVT_KEY_UP(self, self.OnShiftKey)  
      3335  
    3338 3336 # -- code for popup menus -- This isn't working  
    3339 3337         self.Bind(wx.EVT_CONTEXT_MENU, self.OnContextMenuCanvas)  
     
    4827 4825         r = self.pdc.GetIdBounds(dcid)  
    4828 4826         if shape.NodeAID and shape.NodeBID:  # recalculate ends  
      4827             x, y = shape.GetPos()  
    4829 4828             shape.Draw(self.pdc)  
      4829             newx, newy = shape.GetPos()  
      4830             dx, dy = newx - x, newy - y  
    4830 4831         elif shape.NodeAID:  # follow  
    4831 4832             nodea = shape.Get('NodeA')  
     
    4851 4852 #        shape.PosX += dx  # would += work? aparently yes  
    4852 4853 #        shape.PosY += dy  
      4854  
    4853 4855         for follower_shape in shape.GetFollowers():  
    4854 4856             self.MoveID(follower_shape.dcid, dx, dy, 1)  
     
    4867 4869         if debug: print "set focus event received"  
    4868 4870  
      4871     def OnShiftKey(self, event):  
      4872         if event.ShiftDown() or self.demo.draw_mode:  
      4873             self.SetCursor(self.pencil_cursor)  
      4874         else:  
      4875             self.SetCursor(wx.StockCursor(wx.CURSOR_ARROW))  
      4876         event.Skip()  
      4877  
    4869 4878     def OnChar(self, evt):  
    4870 4879         uk = evt.GetUnicodeKey()  
     
    5218 5227         self.demo.draw_mode = False  
    5219 5228         self.report_toolbar.ToggleTool(ID.NORMAL, True)  
      5229         self.win.SetCursor(self.win.pointer_cursor)  
    5220 5230  
    5221 5231     def OnDraw(self, event):  
    5222 5232         self.demo.draw_mode = True  
    5223 5233         self.report_toolbar.ToggleTool(ID.DRAW, True)  
      5234         self.win.SetCursor(self.win.pencil_cursor)  
    5224 5235  
    5225 5236     def OnShiftKey(self, event):  
    5226           if event.ShiftDown():  
      5237         if event.ShiftDown() or self.demo.draw_mode:  
    5226 5237             self.report_toolbar.ToggleTool(ID.DRAW, True)  
    5227 5238         else:  
    5228               if self.demo.draw_mode:  
    5229                   self.report_toolbar.ToggleTool(ID.DRAW, True)  
    5230               else:  
    5231                   self.report_toolbar.ToggleTool(ID.NORMAL, True)  
      5239             self.report_toolbar.ToggleTool(ID.NORMAL, True)  
    5232 5240         event.Skip()  
    5233 5241  
  • ganttpv/trunk/Menu.py

    r447 r451  
    1101 1101     # return wx.Bitmap(os.path.join(Data.Path, "icons", "Report.bmp"), wx.BITMAP_TYPE_BMP)  
    1102 1102  
      1103 def IconPath(path):  
      1104     filename = os.path.basename(path)  
      1105     path = os.path.join(Data.Path, "icons", filename)  
      1106     return path  
      1107  
    1103 1108 if debug: print "end Menu.py"