1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _VCL_CONTROLLAYOUT_HXX 25 #define _VCL_CONTROLLAYOUT_HXX 26 27 #include <vector> 28 #include <tools/gen.hxx> 29 #include <tools/string.hxx> 30 #include <vcl/dllapi.h> 31 32 class Control; 33 34 namespace vcl 35 { 36 37 struct VCL_DLLPUBLIC ControlLayoutData 38 { 39 // contains the string really displayed 40 // there must be exactly one bounding rectangle in m_aUnicodeBoundRects 41 // for every character in m_aDisplayText 42 String m_aDisplayText; 43 // the bounding rectangle of every character 44 // where one character may consist of many glyphs 45 std::vector< Rectangle > m_aUnicodeBoundRects; 46 // start indices of lines 47 std::vector< long > m_aLineIndices; 48 // notify parent control on destruction 49 const Control* m_pParent; 50 ControlLayoutDatavcl::ControlLayoutData51 ControlLayoutData() : m_pParent( NULL ) {} 52 ~ControlLayoutData(); 53 54 Rectangle GetCharacterBounds( long nIndex ) const; 55 // returns the character index for corresponding to rPoint (in control coordinates) 56 // -1 is returned if no character is at that point 57 long GetIndexForPoint( const Point& rPoint ) const; 58 // returns the number of lines in the result of GetDisplayText() 59 long GetLineCount() const; 60 // returns the interval [start,end] of line nLine 61 // returns [-1,-1] for an invalid line 62 Pair GetLineStartEnd( long nLine ) const; 63 /** ToRelativeLineIndex changes a layout data index to a count relative to its line. 64 65 <p>This is equivalent to getting the line start/end pairs with 66 <member>GetLineStartEnd</member> until the index lies within [start,end] of a line 67 </p> 68 69 @param nIndex 70 the absolute index inside the display text to be changed to a relative index 71 72 @returns 73 the relative index inside the displayed line or -1 if the absolute index does 74 not match any line 75 */ 76 long ToRelativeLineIndex( long nIndex ) const; 77 }; 78 79 } // namespace vcl 80 81 #endif // _VCL_CONTROLLAYOUT_HXX 82