tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / toolkit / source / controls / table / tablegeometry.hxx
blobdde156ffd253f42052fd71f51933207765a022ac
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #pragma once
22 #include <controls/table/tabletypes.hxx>
23 #include <tools/gen.hxx>
25 namespace svt::table
29 class TableControl_Impl;
32 //= TableGeometry
34 class TableGeometry
36 protected:
37 const TableControl_Impl& m_rControl;
38 const tools::Rectangle& m_rBoundaries;
39 tools::Rectangle m_aRect;
41 protected:
42 TableGeometry(
43 const TableControl_Impl& _rControl,
44 const tools::Rectangle& _rBoundaries
46 :m_rControl( _rControl )
47 ,m_rBoundaries( _rBoundaries )
48 ,m_aRect( _rBoundaries )
52 public:
53 // attribute access
54 const TableControl_Impl& getControl() const { return m_rControl; }
56 // status
57 const tools::Rectangle& getRect() const { return m_aRect; }
58 bool isValid() const { return !m_aRect.GetIntersection( m_rBoundaries ).IsEmpty(); }
62 //= TableRowGeometry
64 class TableRowGeometry final : public TableGeometry
66 public:
67 TableRowGeometry(
68 TableControl_Impl const & _rControl,
69 tools::Rectangle const & _rBoundaries,
70 RowPos const _nRow,
71 bool const i_allowVirtualRows = false
72 // allow rows >= getRowCount()?
75 // status
76 RowPos getRow() const { return m_nRowPos; }
77 // operations
78 bool moveDown();
80 private:
81 void impl_initRect();
82 bool impl_isValidRow( RowPos const i_row ) const;
84 RowPos m_nRowPos;
85 bool m_bAllowVirtualRows;
89 //= TableColumnGeometry
91 class TableColumnGeometry final : public TableGeometry
93 public:
94 TableColumnGeometry(
95 TableControl_Impl const & _rControl,
96 tools::Rectangle const & _rBoundaries,
97 ColPos const _nCol
100 // status
101 ColPos getCol() const { return m_nColPos; }
102 // operations
103 bool moveRight();
105 private:
106 void impl_initRect();
107 bool impl_isValidColumn( ColPos const i_column ) const;
109 ColPos m_nColPos;
113 //= TableCellGeometry
115 /** a helper representing geometry information of a cell
117 class TableCellGeometry
119 private:
120 TableRowGeometry m_aRow;
121 TableColumnGeometry m_aCol;
123 public:
124 TableCellGeometry(
125 TableControl_Impl const & _rControl,
126 tools::Rectangle const & _rBoundaries,
127 ColPos const _nCol,
128 RowPos const _nRow
130 :m_aRow( _rControl, _rBoundaries, _nRow, false/*allowVirtualCells*/ )
131 ,m_aCol( _rControl, _rBoundaries, _nCol )
135 TableCellGeometry(
136 const TableRowGeometry& _rRow,
137 ColPos _nCol
139 :m_aRow( _rRow )
140 ,m_aCol( _rRow.getControl(), _rRow.getRect(), _nCol )
144 tools::Rectangle getRect() const { return m_aRow.getRect().GetIntersection( m_aCol.getRect() ); }
145 ColPos getColumn() const { return m_aCol.getCol(); }
146 bool isValid() const { return !getRect().IsEmpty(); }
148 bool moveRight() {return m_aCol.moveRight(); }
152 } // namespace svt::table
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */