From e1665b524c9ad3b3f08f0100ebab31a17f9abb30 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Sun, 1 Jun 2003 22:46:00 +0000 Subject: [PATCH] Center list after a quick person add svn: r1621 --- gramps2/src/DrawDoc.py | 2 +- gramps2/src/ListModel.py | 5 ++++ gramps2/src/SelectChild.py | 1 + gramps2/src/docgen/PdfDrawDoc.py | 41 ++++++++++---------------------- 4 files changed, 19 insertions(+), 30 deletions(-) diff --git a/gramps2/src/DrawDoc.py b/gramps2/src/DrawDoc.py index 033ad36df..83cb6ecfa 100644 --- a/gramps2/src/DrawDoc.py +++ b/gramps2/src/DrawDoc.py @@ -188,7 +188,7 @@ class DrawDoc: def line_to(self,x,y): pass - def arc_to(self,x,y): + def arc_to(self,x,y,angle,extent): pass def end_path(self): diff --git a/gramps2/src/ListModel.py b/gramps2/src/ListModel.py index 087904a0a..3137516b4 100644 --- a/gramps2/src/ListModel.py +++ b/gramps2/src/ListModel.py @@ -186,6 +186,11 @@ class ListModel: col = col + 1 self.model.set_value(iter,col,info) self.selection.select_iter(iter) + + def center_selected(self): + model,iter = self.selection.get_selected() + path = model.get_path(iter) + self.tree.scroll_to_cell(path,None,gtk.TRUE,0.5,0.5) def button_press(self,obj,event): if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1: diff --git a/gramps2/src/SelectChild.py b/gramps2/src/SelectChild.py index 2fa43da49..a6c1e6cd5 100644 --- a/gramps2/src/SelectChild.py +++ b/gramps2/src/SelectChild.py @@ -257,6 +257,7 @@ class SelectChild: rdata = [dinfo[0],dinfo[1],dinfo[3],dinfo[5],dinfo[6]] self.refmodel.add_and_select(rdata) self.add_person(person) + self.refmodel.center_selected() def north_american(self,val): if self.person.getGender() == Person.male: diff --git a/gramps2/src/docgen/PdfDrawDoc.py b/gramps2/src/docgen/PdfDrawDoc.py index 74009b05c..a0fcfdbf2 100644 --- a/gramps2/src/docgen/PdfDrawDoc.py +++ b/gramps2/src/docgen/PdfDrawDoc.py @@ -152,25 +152,7 @@ class PdfDrawDoc(DrawDoc.DrawDoc): else: self.f.drawPath(p,stroke=1,fill=0) - def start_path(self,style,x,y): - self.active_path = self.f.beginPath() - self.active_path.move_to(x+self.lmargin,y=self.tmargin) - self.active_style = style - - def line_to(self,x,y): - self.active_path.line_to(x+self.lmargin,y+self.tmargin) - - def arc_to(self,x,y): - self.active_path.arc_to(x+self.lmargin,y+self.tmargin) - - def end_path(self): - self.f.draw_path(self.active_path,stroke=1,fill=1) - - def draw_arc(self,style,x1,y1,x2,y2,angle,extent): - x1 += self.lmargin - y1 += self.tmargin - x2 += self.lmargin - y2 += self.tmargin + def draw_half_circle(self,style,x,y,radius): stype = self.draw_styles[style] if stype.get_line_style() == DrawDoc.SOLID: @@ -182,18 +164,19 @@ class PdfDrawDoc(DrawDoc.DrawDoc): color = stype.get_fill_color() self.f.setFillColor((float(color[0])/255.0,float(color[1])/255.0,float(color[2])/255.0)) + x0 = (x+self.lmargin)*cm + y0 = (y+self.tmargin)*cm + r = radius*cm + p = self.f.beginPath() - p.arc(x1*cm,y1*cm,x2*cm,y2*cm,angle,extent) - + p.moveTo(x0-r,y0) + p.arcTo(x0-r,y0-(r/2),x0+r,y0+(r/2)) + p.lineTo(x0-r,y0) + self.f.drawPath(p,fill=1,stroke=1) + +# self.f.arc(x0-r,y0-r,x0+r,y0+r,180,180) +# self.f.line(x0-r,y0,x0+r,y0) fill = stype.get_color() - - print x1*cm,y1*cm,x2*cm,y2*cm,angle,extent - - self.f.drawPath(p,stroke=1,fill=0) -# if fill[0] == 0: -# self.f.drawPath(p,stroke=1,fill=1) -# else: -# self.f.drawPath(p,stroke=1,fill=0) def draw_box(self,style,text,x,y): x = x + self.lmargin