Exemplo n.º 1
0
 def expandFrame(self):
     """Text is inserted into a frame without regard to frame size.
      Later we expand the frame to fit the text, carrying text to
      a new frame if necessary."""
     numcarries = 0
     self.raiseImages()
     if self.frame != None:
         while scribus.textOverflows(self.frame, ) > 0:
             (x, y) = scribus.getPosition(self.frame)
             (width, height) = scribus.getSize(self.frame)
             if y + height < self.pageheight - self.bottommargin:
                 scribus.sizeObject(width, height + 1, self.frame)
             else:
                 fullpage = (y <= self.topmargin and self.columns == 1)
                 if self.buffer != [] and not self.framelinked and numcarries < 4 and not fullpage:
                     numcarries = numcarries + 1
                     scribus.deselectAll()
                     scribus.deleteText(self.frame)
                     for (content, style) in self.contents:
                         self.styleText(content, style, self.frame)
                     newcontents = self.buffer[:]
                     self.newFrame(columns=self.columns)
                     for (content, style) in newcontents:
                         self.styleText(content, style, self.frame)
                     self.buffer = newcontents[:]
                 else:
                     lastframe = self.frame
                     self.newFrame(columns=self.columns)
                     scribus.linkTextFrames(lastframe, self.frame)
                     self.framelinked = True
             self.raiseImages()
Exemplo n.º 2
0
    def drawIndexByName(self):
        contents = {}
        climbnames = []
        for (route, grade, stars, crag, page) in self.climbs:
            text = route + chr(TAB) + str(page)
            contents[route] = (text, "Index")
            climbnames.append(route)
        climbnames.sort()

        (width, height) = scribus.getPageSize()
        (top, left, right, bottom) = getCurrentPageMargins()
        frame = scribus.createText(left, top, width - right - left, TITLESIZE)
        insertTextWithStyle("Index by Route Name", "Title", frame)

        frame = scribus.createText(left, top + TITLESIZE, width - right - left,
                                   height - top - bottom - TITLESIZE)
        scribus.setColumns(2, frame)
        scribus.setColumnGap(COLUMNGAP, frame)
        for route in climbnames:
            (text, style) = contents[route]
            insertTextWithStyle(text, style, frame)
            if scribus.textOverflows(frame):
                oldframe = frame
                scribus.newPage(-1)
                (top, left, right, bottom) = getCurrentPageMargins()
                frame = scribus.createText(left, top + TITLESIZE,
                                           width - right - left,
                                           height - top - bottom - TITLESIZE)
                scribus.setColumns(2, frame)
                scribus.setColumnGap(COLUMNGAP, frame)
                scribus.linkTextFrames(oldframe, frame)
Exemplo n.º 3
0
 def flow(self):
     while(scribus.textOverflows(self.name) > 0 and scribus.getTextLines(self.name)):
         current = self.name
         scribus.newPage(-1)
         scribus.gotoPage( scribus.pageCount() )
         self.name = self.make_textframe()
         scribus.linkTextFrames(current, self.name)
Exemplo n.º 4
0
    def draw(self, tolevel):
        contents = []
        for (label, level, page) in self.sections:
            if level <= tolevel:
                text = label + chr(TAB) + str(page)
                style = "Contents" + str(level)
                contents.append((text, style))

        page = self.contentspage
        scribus.gotoPage(page)
        (width, height) = scribus.getPageSize()
        (top, left, right, bottom) = getCurrentPageMargins()
        frame = scribus.createText(left, top, width - right - left, TITLESIZE)
        insertTextWithStyle("Contents", "Title", frame)

        frame = scribus.createText(left, top + TITLESIZE, width - right - left,
                                   height - top - bottom - TITLESIZE)
        scribus.setColumns(2, frame)
        scribus.setColumnGap(COLUMNGAP, frame)
        for (text, style) in contents:
            insertTextWithStyle(text, style, frame)
            if scribus.textOverflows(frame):
                oldframe = frame
                page = page + 1
                scribus.gotoPage(page)
                (top, left, right, bottom) = getCurrentPageMargins()
                frame = scribus.createText(left, top + TITLESIZE,
                                           width - right - left,
                                           height - top - bottom - TITLESIZE)
                scribus.setColumns(2, frame)
                scribus.setColumnGap(COLUMNGAP, frame)
                scribus.linkTextFrames(oldframe, frame)
Exemplo n.º 5
0
 def expandFrame(self):
    """Text is inserted into a frame without regard to frame size.
       Later we expand the frame to fit the text, carrying text to
       a new frame if necessary."""
    numcarries = 0
    self.raiseImages()
    if self.frame != None:
       while scribus.textOverflows(self.frame,) > 0:
          (x,y) = scribus.getPosition(self.frame)
          (width,height) = scribus.getSize(self.frame)
          if y + height < self.pageheight - self.bottommargin:
             scribus.sizeObject(width, height + 1, self.frame)
          else:
             fullpage = (y <= self.topmargin and self.columns == 1)
             if self.buffer != [] and not self.framelinked and numcarries < 4 and not fullpage:
                numcarries = numcarries + 1
                scribus.deselectAll()
                scribus.deleteText(self.frame)
                for (content,style) in self.contents:
                   self.styleText(content,style,self.frame)
                newcontents = self.buffer[:]
                self.newFrame(columns=self.columns)
                for (content,style) in newcontents:
                   self.styleText(content,style,self.frame)
                self.buffer = newcontents[:]
             else:
                lastframe = self.frame
                self.newFrame(columns=self.columns)
                scribus.linkTextFrames(lastframe,self.frame)
                self.framelinked = True
          self.raiseImages()
Exemplo n.º 6
0
 def drawIndexByName(self):
    contents = {}
    climbnames = []
    for (route, grade, stars, crag, page) in self.climbs:
       text = route + chr(TAB) + str(page)
       contents[route] = (text,"Index")
       climbnames.append(route)
    climbnames.sort() 
    
    (width,height) = scribus.getPageSize()
    (top,left,right,bottom) = getCurrentPageMargins()
    frame = scribus.createText(left, top, width-right-left, TITLESIZE)
    insertTextWithStyle("Index by Route Name","Title",frame)
    
    frame = scribus.createText(left, top+TITLESIZE, width-right-left, height-top-bottom-TITLESIZE)
    scribus.setColumns(2,frame)
    scribus.setColumnGap(COLUMNGAP,frame)
    for route in climbnames:
       (text,style) = contents[route]
       insertTextWithStyle(text,style,frame)
       if scribus.textOverflows(frame):
          oldframe = frame
          scribus.newPage(-1)
          (top,left,right,bottom) = getCurrentPageMargins()
          frame = scribus.createText(left, top+TITLESIZE, width-right-left, height-top-bottom-TITLESIZE)
          scribus.setColumns(2,frame)
          scribus.setColumnGap(COLUMNGAP,frame)
          scribus.linkTextFrames(oldframe,frame)
Exemplo n.º 7
0
 def draw(self, tolevel):
    contents = []
    for (label,level,page) in self.sections:
       if level <= tolevel:
          text = label + chr(TAB) + str(page)
          style = "Contents" + str(level)
          contents.append((text,style))
    
    page = self.contentspage
    scribus.gotoPage(page)
    (width,height) = scribus.getPageSize()
    (top,left,right,bottom) = getCurrentPageMargins()
    frame = scribus.createText(left, top, width-right-left, TITLESIZE)
    insertTextWithStyle("Contents","Title",frame)
    
    frame = scribus.createText(left, top+TITLESIZE, width-right-left, height-top-bottom-TITLESIZE)
    scribus.setColumns(2,frame)
    scribus.setColumnGap(COLUMNGAP,frame)
    for (text,style) in contents:
       insertTextWithStyle(text,style,frame)
       if scribus.textOverflows(frame):
          oldframe = frame
          page = page + 1
          scribus.gotoPage(page)
          (top,left,right,bottom) = getCurrentPageMargins()
          frame = scribus.createText(left, top+TITLESIZE, width-right-left, height-top-bottom-TITLESIZE)
          scribus.setColumns(2,frame)
          scribus.setColumnGap(COLUMNGAP,frame)
          scribus.linkTextFrames(oldframe,frame)
Exemplo n.º 8
0
    def drawIndexByGrade(self):
        grades = []
        climbsatgrade = {}
        for (route, gradestr, stars, crag, page) in self.climbs:
            grade = (" " + gradestr.replace("?", "")).center(3, " ")
            if grade != "   " and route[-5:] != ", The":
                if not grade in grades: grades.append(grade)
                routename = route + " " + stars
                if not grade in climbsatgrade:
                    climbsatgrade[grade] = [(routename, page)]
                else:
                    climbsatgrade[grade] = climbsatgrade[grade] + [
                        (routename, page)
                    ]
        grades.sort()

        (width, height) = scribus.getPageSize()
        (top, left, right, bottom) = getCurrentPageMargins()
        frame = scribus.createText(left, top, width - right - left, TITLESIZE)
        insertTextWithStyle("Index by Grade", "Title", frame)

        frame = scribus.createText(left, top + TITLESIZE, width - right - left,
                                   height - top - bottom - TITLESIZE)
        scribus.setColumns(2, frame)
        scribus.setColumnGap(COLUMNGAP, frame)
        for grade in grades:
            insertTextWithStyle("Grade " + grade, "IndexGrade", frame)

            for climb in climbsatgrade[grade]:
                (route, page) = climb
                text = route + chr(TAB) + str(page)
                insertTextWithStyle(text, "Index", frame)
            if scribus.textOverflows(frame):
                oldframe = frame
                scribus.newPage(-1)
                (top, left, right, bottom) = getCurrentPageMargins()
                frame = scribus.createText(left, top + TITLESIZE,
                                           width - right - left,
                                           height - top - bottom - TITLESIZE)
                scribus.setColumns(2, frame)
                scribus.setColumnGap(COLUMNGAP, frame)
                scribus.linkTextFrames(oldframe, frame)
Exemplo n.º 9
0
 def createNewPage(self, tbox):
     curPage = scribus.currentPage()
     if curPage < scribus.pageCount() - 1:
         where = curPage + 1
     else:
         where = -1
     logger.debug("cur=%d name=%s pc=%d wh=%d", curPage, tbox,
                  scribus.pageCount(), where)
     cols = scribus.getColumns(tbox)
     colgap = scribus.getColumnGap(tbox)
     x, y = scribus.getPosition(tbox)
     w, h = scribus.getSize(tbox)
     mp = scribus.getMasterPage(curPage)
     scribus.newPage(where, mp)  # return val?
     scribus.gotoPage(curPage + 1)
     newBox = scribus.createText(x, y, w, h)
     scribus.setColumns(cols, newBox)
     scribus.setColumnGap(colgap, newBox)
     scribus.linkTextFrames(tbox, newBox)
     logger.debug("link from %s to %s", tbox, newBox)
     return newBox
Exemplo n.º 10
0
 def drawIndexByGrade(self):
    grades = []
    climbsatgrade = {}
    for (route, gradestr, stars, crag, page) in self.climbs:
       grade = (" " + gradestr.replace("?","")).center(3," ")
       if grade != "   " and route[-5:] != ", The":
          if not grade in grades: grades.append(grade)
          routename = route + " " + stars
          if not grade in climbsatgrade: 
             climbsatgrade[grade] = [(routename,page)]
          else:
             climbsatgrade[grade] = climbsatgrade[grade] + [(routename,page)]
    grades.sort() 
    
    (width,height) = scribus.getPageSize()
    (top,left,right,bottom) = getCurrentPageMargins()
    frame = scribus.createText(left, top, width-right-left, TITLESIZE)
    insertTextWithStyle("Index by Grade","Title",frame)
    
    frame = scribus.createText(left, top+TITLESIZE, width-right-left, height-top-bottom-TITLESIZE)
    scribus.setColumns(2,frame)
    scribus.setColumnGap(COLUMNGAP,frame)
    for grade in grades:
       insertTextWithStyle("Grade " + grade,"IndexGrade",frame)
    
       for climb in climbsatgrade[grade]:
          (route,page) = climb
          text = route + chr(TAB) + str(page)
          insertTextWithStyle(text,"Index",frame)
       if scribus.textOverflows(frame):
          oldframe = frame
          scribus.newPage(-1)
          (top,left,right,bottom) = getCurrentPageMargins()
          frame = scribus.createText(left, top+TITLESIZE, width-right-left, height-top-bottom-TITLESIZE)
          scribus.setColumns(2,frame)
          scribus.setColumnGap(COLUMNGAP,frame)
          scribus.linkTextFrames(oldframe,frame)