From e1e76c7813015a203b0c9ecf6ecd461ae230b57e Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Thu, 15 Jan 2004 07:18:38 +0000 Subject: [PATCH] Moved these files to /current/headers/private/interface git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6095 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../BTextView/TextViewSupportBuffer.h | 149 ------------------ src/kits/interface/BTextView/WidthBuffer.h | 41 ----- src/kits/interface/BTextView/moreUTF8.h | 45 ------ 3 files changed, 235 deletions(-) delete mode 100644 src/kits/interface/BTextView/TextViewSupportBuffer.h delete mode 100644 src/kits/interface/BTextView/WidthBuffer.h delete mode 100644 src/kits/interface/BTextView/moreUTF8.h diff --git a/src/kits/interface/BTextView/TextViewSupportBuffer.h b/src/kits/interface/BTextView/TextViewSupportBuffer.h deleted file mode 100644 index 58575336ce..0000000000 --- a/src/kits/interface/BTextView/TextViewSupportBuffer.h +++ /dev/null @@ -1,149 +0,0 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2001-2003, OpenBeOS -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -// -// File Name: TextViewSupportBuffer.h -// Author: Marc Flerackers (mflerackers@androme.be) -// Description: Template class used to implement the various BTextView -// buffer classes. -//------------------------------------------------------------------------------ - -#ifndef __TEXT_VIEW_SUPPORT_BUFFER__H__ -#define __TEXT_VIEW_SUPPORT_BUFFER__H__ - -// Standard Includes ----------------------------------------------------------- -#include -#include - -// System Includes ------------------------------------------------------------- -#include - -// Project Includes ------------------------------------------------------------ - -// Local Includes -------------------------------------------------------------- - -// Local Defines --------------------------------------------------------------- - -// Globals --------------------------------------------------------------------- - -// _BTextViewSupportBuffer_ class ---------------------------------------------- -template -class _BTextViewSupportBuffer_ { - -public: - _BTextViewSupportBuffer_(int32 inExtraCount = 0, int32 inCount = 0); -virtual ~_BTextViewSupportBuffer_(); - - void InsertItemsAt(int32 inNumItems, int32 inAtIndex, const T *inItem); - void RemoveItemsAt(int32 inNumItems, int32 inAtIndex); - - int32 ItemCount() const; - -protected: - int32 fExtraCount; - int32 fItemCount; - int32 fBufferCount; - T* fBuffer; -}; -//------------------------------------------------------------------------------ -template -_BTextViewSupportBuffer_::_BTextViewSupportBuffer_(int32 inExtraCount, - int32 inCount) - : fExtraCount(inExtraCount), - fItemCount(inCount), - fBufferCount(fExtraCount + fItemCount), - fBuffer(NULL) -{ - fBuffer = (T *)calloc(fExtraCount + fItemCount, sizeof(T)); -} -//------------------------------------------------------------------------------ -template -_BTextViewSupportBuffer_::~_BTextViewSupportBuffer_() -{ - free(fBuffer); -} -//------------------------------------------------------------------------------ -template -void _BTextViewSupportBuffer_::InsertItemsAt(int32 inNumItems, - int32 inAtIndex, - const T *inItem) -{ - if (inNumItems < 1) - return; - - inAtIndex = (inAtIndex > fItemCount) ? fItemCount : inAtIndex; - inAtIndex = (inAtIndex < 0) ? 0 : inAtIndex; - - int32 delta = inNumItems * sizeof(T); - int32 logSize = fItemCount * sizeof(T); - if ((logSize + delta) >= fBufferCount) { - fBufferCount = logSize + delta + (fExtraCount * sizeof(T)); - fBuffer = (T *)realloc(fBuffer, fBufferCount); - } - - T *loc = fBuffer + inAtIndex; - memmove(loc + inNumItems, loc, (fItemCount - inAtIndex) * sizeof(T)); - memcpy(loc, inItem, delta); - - fItemCount += inNumItems; -} -//------------------------------------------------------------------------------ -template -void -_BTextViewSupportBuffer_::RemoveItemsAt(int32 inNumItems, - int32 inAtIndex) -{ - if (inNumItems < 1) - return; - - inAtIndex = (inAtIndex > fItemCount - 1) ? (fItemCount - 1) : inAtIndex; - inAtIndex = (inAtIndex < 0) ? 0 : inAtIndex; - - T *loc = fBuffer + inAtIndex; - memmove(loc, loc + inNumItems, - (fItemCount - (inNumItems + inAtIndex)) * sizeof(T)); - - int32 delta = inNumItems * sizeof(T); - int32 logSize = fItemCount * sizeof(T); - uint32 extraSize = fBufferCount - (logSize - delta); - if (extraSize > (fExtraCount * sizeof(T))) { - fBufferCount = (logSize - delta) + (fExtraCount * sizeof(T)); - fBuffer = (T *)realloc(fBuffer, fBufferCount); - } - - fItemCount -= inNumItems; -} -//------------------------------------------------------------------------------ -template -inline int32 -_BTextViewSupportBuffer_::ItemCount() const -{ - return fItemCount; -} -//------------------------------------------------------------------------------ - -#endif // __TEXT_VIEW_SUPPORT_BUFFER__H__ - -/* - * $Log $ - * - * $Id $ - * - */ diff --git a/src/kits/interface/BTextView/WidthBuffer.h b/src/kits/interface/BTextView/WidthBuffer.h deleted file mode 100644 index 0c1ea6197c..0000000000 --- a/src/kits/interface/BTextView/WidthBuffer.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef __WIDTHBUFFER_H -#define __WIDTHBUFFER_H - -#include "TextGapBuffer.h" -#include "TextViewSupportBuffer.h" - - -struct _width_table_ { -#if B_BEOS_VERSION_DANO - BFont font; // corresponding font -#else - int32 fontCode; // font code - float fontSize; // font size -#endif - int32 hashCount; // number of hashed items - int32 tableCount; // size of table - void *widths; // width table -}; - - -class _BWidthBuffer_ : public _BTextViewSupportBuffer_<_width_table_> { -public: - _BWidthBuffer_(); - virtual ~_BWidthBuffer_(); - - float StringWidth(const char *inText, int32 fromOffset, int32 length, - const BFont *inStyle); - float StringWidth(_BTextGapBuffer_ &, int32 fromOffset, int32 length, - const BFont *inStyle); - -private: - bool FindTable(const BFont *font, int32 *outIndex); - int32 InsertTable(const BFont *font); - - bool GetEscapement(uint32, int32, float *); - float HashEscapements(const char *, int32, int32, int32, const BFont *); - - static uint32 Hash(uint32); -}; - -#endif // __WIDTHBUFFER_H diff --git a/src/kits/interface/BTextView/moreUTF8.h b/src/kits/interface/BTextView/moreUTF8.h deleted file mode 100644 index 88ca0172f7..0000000000 --- a/src/kits/interface/BTextView/moreUTF8.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef __MOREUTF8 -#define __MOREUTF8 - - -static inline bool -IsInsideGlyph(uchar ch) -{ - return (ch & 0xC0) == 0x80; -} - - -static inline uint32 -UTF8NextCharLen(const char *text) -{ - const char *ptr = text; - - if (ptr == NULL || *ptr == 0) - return 0; - - do { - ptr++; - } while (IsInsideGlyph(*ptr)); - - return ptr - text; -} - - -static inline uint32 -UTF8PreviousCharLen(const char *text, const char *limit) -{ - const char *ptr = text; - - if (ptr == NULL || limit == NULL) - return 0; - - do { - if (ptr == limit) - break; - ptr--; - } while (IsInsideGlyph(*ptr)); - - return text - ptr; -} - -#endif