File indexing completed on 2024-05-12 04:33:55
0001 // -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; c-brace-offset: 0; -*- 0002 // 0003 // anchor.h 0004 // 0005 // Part of KVIEWSHELL - A framework for multipage text/gfx viewers 0006 // 0007 // SPDX-FileCopyrightText: 2004-2005 Stefan Kebekus 0008 // SPDX-License-Identifier: GPL-2.0-or-later 0009 0010 #ifndef ANCHOR_H 0011 #define ANCHOR_H 0012 0013 #include "length.h" 0014 #include "pageNumber.h" 0015 0016 /** \brief Page number and vertical position in physical coordinates 0017 0018 This very simple class contains a page number and a vertical position 0019 in physical coordinates. The vertical position is given by the 0020 distance from the top of the page. Anchors are completely independent 0021 of documents, there is no need for a document to exists that contains 0022 the given page, nor does the page number need to be valid. 0023 0024 @author Stefan Kebekus <kebekus@kde.org> 0025 @version 1.0 0 0026 */ 0027 0028 class Anchor 0029 { 0030 public: 0031 /** \brief Constructs an anchor that points to an invalid page */ 0032 Anchor() 0033 : page(0) 0034 { 0035 } 0036 0037 /** \brief Constructs an anchor that points to a given position on a 0038 given page 0039 0040 The class contains no code to make sure in any way that the page 0041 number pg exists, and that page pg, if it exists, is taller than 0042 distance_from_top 0043 0044 @param pg number of the page 0045 @param _distance_from_top distance from the top of the page 0046 */ 0047 Anchor(quint16 pg, const Length _distance_from_top) 0048 : page(pg) 0049 , distance_from_top(_distance_from_top) 0050 { 0051 } 0052 0053 /** \brief quick validity check for anchors 0054 0055 @returns true if the page number is valid, and 0mm <= distance_from_top <= 2m 0056 */ 0057 bool isValid() const 0058 { 0059 return page.isValid() && (0.0 <= distance_from_top.getLength_in_mm()) && (distance_from_top.getLength_in_mm() <= 2000.0); 0060 } 0061 0062 /** \brief Page number that this anchor point to */ 0063 PageNumber page; 0064 0065 /** \brief Distance from the top of the page in inch */ 0066 Length distance_from_top; 0067 }; 0068 0069 #endif