parameters: (self, force)
return_statement: return force
docstring: Compute the required buffer sizes to hold the viewed rectangle and
              the range of pages visible. Override force flag and set true if 
              the current set of rendered pages changes
docstring_summary: Compute the required buffer sizes to hold the viewed rectangle and
              the range of pages visible. Override force flag and set true if 
              the current set of rendered pages changes
docstring_tokens: Compute the required buffer sizes to hold the viewed rectangle and the range of pages visible . Override force flag and set true if the current set of rendered pages changes
function: def CalculateDimensions(self, force):
          """ Compute the required buffer sizes to hold the viewed rectangle and
              the range of pages visible. Override force flag and set true if 
              the current set of rendered pages changes
          """
          self.frompage = 0
          self.topage = 0
          self.clientdc = dc = wx.ClientDC(self)      # dc for device scaling 
          self.device_scale = dc.GetPPI()[0]/72.0     # pixels per inch / points per inch 
          if wx.PlatformInfo[1] == 'wxMSW': 
              # for Windows only wx.GraphicsContext fonts are too big in the ratio  
              # of screen pixels per inch to points per inch 
              self.font_scale = 1.0 / self.device_scale
          else:
              self.font_scale = 1.0
                                         
          self.winwidth, self.winheight = self.GetClientSizeTuple()
          if self.winheight < 100:
              return
          self.Ypage = self.pageheight + self.nom_page_gap
          if self.zoomscale > 0.0:
              self.scale = self.zoomscale * self.device_scale
          else:
              if int(self.zoomscale) == -1:   # fit width
                  self.scale = self.winwidth / self.pagewidth
              else:                           # fit page
                  self.scale = self.winheight / self.pageheight
          self.Xpagepixels = int(round(self.pagewidth*self.scale))
          self.Ypagepixels = int(round(self.Ypage*self.scale))
  
          # adjust inter-page gap so Ypagepixels is a whole number of scroll increments
          # and page numbers change precisely on a scroll click
          idiv = self.Ypagepixels/self.scrollrate
          nlo = idiv * self.scrollrate
          nhi = (idiv + 1) * self.scrollrate
          if nhi - self.Ypagepixels < self.Ypagepixels - nlo:
              self.Ypagepixels = nhi
          else:
              self.Ypagepixels = nlo
          self.page_gap = self.Ypagepixels/self.scale - self.pageheight   
  
          self.maxwidth = max(self.winwidth, self.Xpagepixels)
          self.maxheight = max(self.winheight, self.numpages*self.Ypagepixels)
          self.SetVirtualSize((self.maxwidth, self.maxheight))
          self.SetScrollRate(self.scrollrate,self.scrollrate)
  
          xv, yv = self.GetViewStart()
          dx, dy = self.GetScrollPixelsPerUnit()
          self.x0, self.y0   = (xv * dx, yv * dy)
          self.frompage = min(self.y0/self.Ypagepixels, self.numpages-1)
          self.topage = min((self.y0+self.winheight-1)/self.Ypagepixels, self.numpages-1)
          self.pagebufferwidth = max(self.Xpagepixels, self.winwidth)
          self.pagebufferheight = (self.topage - self.frompage + 1) * self.Ypagepixels
  
          # Inform buttonpanel controls of any changes
          if self.buttonpanel:
              self.buttonpanel.Update(self.frompage, self.numpages,
                                        self.scale/self.device_scale)
  
          self.page_y0 = self.frompage * self.Ypagepixels
          self.page_x0 = 0
          self.xshift = self.x0 - self.page_x0
          self.yshift = self.y0 - self.page_y0
          if force:               # by external request 
              self.cur_frompage = self.frompage
              self.cur_topage = self.topage
          else:   # page range unchanged? whole visible area will always be inside page buffer
              if self.frompage <> self.cur_frompage or self.topage <> self.cur_topage:  
                  force = True    # due to page buffer change
                  self.cur_frompage = self.frompage
                  self.cur_topage = self.topage
          return force
function_tokens: def CalculateDimensions ( self , force ) : self . frompage = 0 self . topage = 0 self . clientdc = dc = wx . ClientDC ( self ) # dc for device scaling  self . device_scale = dc . GetPPI ( ) [ 0 ] / 72.0 # pixels per inch / points per inch  if wx . PlatformInfo [ 1 ] == 'wxMSW' : # for Windows only wx.GraphicsContext fonts are too big in the ratio   # of screen pixels per inch to points per inch  self . font_scale = 1.0 / self . device_scale else : self . font_scale = 1.0 self . winwidth , self . winheight = self . GetClientSizeTuple ( ) if self . winheight < 100 : return self . Ypage = self . pageheight + self . nom_page_gap if self . zoomscale > 0.0 : self . scale = self . zoomscale * self . device_scale else : if int ( self . zoomscale ) == - 1 : # fit width self . scale = self . winwidth / self . pagewidth else : # fit page self . scale = self . winheight / self . pageheight self . Xpagepixels = int ( round ( self . pagewidth * self . scale ) ) self . Ypagepixels = int ( round ( self . Ypage * self . scale ) ) # adjust inter-page gap so Ypagepixels is a whole number of scroll increments # and page numbers change precisely on a scroll click idiv = self . Ypagepixels / self . scrollrate nlo = idiv * self . scrollrate nhi = ( idiv + 1 ) * self . scrollrate if nhi - self . Ypagepixels < self . Ypagepixels - nlo : self . Ypagepixels = nhi else : self . Ypagepixels = nlo self . page_gap = self . Ypagepixels / self . scale - self . pageheight self . maxwidth = max ( self . winwidth , self . Xpagepixels ) self . maxheight = max ( self . winheight , self . numpages * self . Ypagepixels ) self . SetVirtualSize ( ( self . maxwidth , self . maxheight ) ) self . SetScrollRate ( self . scrollrate , self . scrollrate ) xv , yv = self . GetViewStart ( ) dx , dy = self . GetScrollPixelsPerUnit ( ) self . x0 , self . y0 = ( xv * dx , yv * dy ) self . frompage = min ( self . y0 / self . Ypagepixels , self . numpages - 1 ) self . topage = min ( ( self . y0 + self . winheight - 1 ) / self . Ypagepixels , self . numpages - 1 ) self . pagebufferwidth = max ( self . Xpagepixels , self . winwidth ) self . pagebufferheight = ( self . topage - self . frompage + 1 ) * self . Ypagepixels # Inform buttonpanel controls of any changes if self . buttonpanel : self . buttonpanel . Update ( self . frompage , self . numpages , self . scale / self . device_scale ) self . page_y0 = self . frompage * self . Ypagepixels self . page_x0 = 0 self . xshift = self . x0 - self . page_x0 self . yshift = self . y0 - self . page_y0 if force : # by external request  self . cur_frompage = self . frompage self . cur_topage = self . topage else : # page range unchanged? whole visible area will always be inside page buffer if self . frompage <> self . cur_frompage or self . topage <> self . cur_topage : force = True # due to page buffer change self . cur_frompage = self . frompage self . cur_topage = self . topage return force