-- |
pageArrFuncCont :: DesktopConstraint
                -> Hoodle EditMode 
                -> PageNum 
                -> Maybe (PageOrigin,PageDimension) 
pageArrFuncCont (DesktopWidthConstrained w') hdl (PageNum n)
  | n < 0 = Nothing
  | n >= len = Nothing
  | otherwise = Just (PageOrigin (xys !! n), PageDimension (pdims !! n))
  where addf (x,y) (w,h) = if x+2*w+predefinedPageSpacing < w'   
                             then (x+w+predefinedPageSpacing,y)
                             else (0,y+h+predefinedPageSpacing)
        pgs = toList . view gpages $ hdl 
        len = length pgs 
        pdims = map (view gdimension) pgs 
        wh2xyFrmPg = ((,) <$> dim_width <*> dim_height) . view gdimension
        xys = scanl addf (0,0) . map wh2xyFrmPg $ pgs  

-- |
pageArrFuncCont :: DesktopConstraint
                -> Hoodle EditMode 
                -> PageNum 
                -> Maybe (PageOrigin,PageDimension)
pageArrFuncCont (DesktopWidthConstrained w') hdl (PageNum n)
  | n < 0 = Nothing
  | n >= len = Nothing
  | otherwise = Just (PageOrigin (xys !! n), PageDimension (pdims !! n))
  where addf (x,y) (w,h) = if x+2*w+predefinedPageSpacing < w'   
                             then (x+w+predefinedPageSpacing,y)
                             else (0,y+h+predefinedPageSpacing)
        pgs = toList . view gpages $ hdl 
        len = length pgs 
        pdims = map (view gdimension) pgs 
        wh2xyFrmPg = ((,) <$> dim_width <*> dim_height) . view gdimension
        xys = scanl addf (0,0) . map wh2xyFrmPg $ pgs  

-- |
pageArrFuncCont (DesktopWidthConstrained w') hdl (PageNum n)
  | n < 0 = Nothing
  | n >= len = Nothing
  | otherwise = Just (PageOrigin (xys !! n), PageDimension (pdims !! n))
  where addf (x,y) (w,h) = if x+2*w+predefinedPageSpacing < w'   
                             then (x+w+predefinedPageSpacing,y)
                             else (0,y+h+predefinedPageSpacing)
        pgs = toList . view gpages $ hdl 
        len = length pgs 
        pdims = map (view gdimension) pgs 
        wh2xyFrmPg = ((,) <$> dim_width <*> dim_height) . view gdimension
        xys = scanl addf (0,0) . map wh2xyFrmPg $ pgs  

-- |