Use the Bfont object to discriminate between fonts (as in Dano)
and not just size and code. Style cleanups. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37369 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,30 +1,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2004, Haiku, Inc.
|
||||
//
|
||||
// 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
|
||||
// Authors Marc Flerackers ([email protected])
|
||||
// Stefano Ceccherini ([email protected])
|
||||
// Description: Template class used to implement the various BTextView
|
||||
// buffer classes.
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
* Copyright 2001-2010, Haiku, Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#ifndef __TEXT_VIEW_SUPPORT_BUFFER__H__
|
||||
#define __TEXT_VIEW_SUPPORT_BUFFER__H__
|
||||
@@ -44,7 +21,7 @@ public:
|
||||
_BTextViewSupportBuffer_(int32 inExtraCount = 0, int32 inCount = 0);
|
||||
virtual ~_BTextViewSupportBuffer_();
|
||||
|
||||
void InsertItemsAt(int32 inNumItems, int32 inAtIndex, const T *inItem);
|
||||
void InsertItemsAt(int32 inNumItems, int32 inAtIndex, const T* inItem);
|
||||
void RemoveItemsAt(int32 inNumItems, int32 inAtIndex);
|
||||
|
||||
int32 ItemCount() const;
|
||||
@@ -65,7 +42,7 @@ _BTextViewSupportBuffer_<T>::_BTextViewSupportBuffer_(int32 inExtraCount,
|
||||
fBufferCount(fExtraCount + fItemCount),
|
||||
fBuffer(NULL)
|
||||
{
|
||||
fBuffer = (T *)calloc(fExtraCount + fItemCount, sizeof(T));
|
||||
fBuffer = (T*)calloc(fExtraCount + fItemCount, sizeof(T));
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +57,7 @@ template <class T>
|
||||
void
|
||||
_BTextViewSupportBuffer_<T>::InsertItemsAt(int32 inNumItems,
|
||||
int32 inAtIndex,
|
||||
const T *inItem)
|
||||
const T* inItem)
|
||||
{
|
||||
if (inNumItems < 1)
|
||||
return;
|
||||
@@ -92,12 +69,12 @@ _BTextViewSupportBuffer_<T>::InsertItemsAt(int32 inNumItems,
|
||||
int32 logSize = fItemCount * sizeof(T);
|
||||
if ((logSize + delta) >= fBufferCount) {
|
||||
fBufferCount = logSize + delta + (fExtraCount * sizeof(T));
|
||||
fBuffer = (T *)realloc(fBuffer, fBufferCount);
|
||||
fBuffer = (T*)realloc(fBuffer, fBufferCount);
|
||||
if (fBuffer == NULL)
|
||||
debugger("InsertItemsAt(): reallocation failed");
|
||||
}
|
||||
|
||||
T *loc = fBuffer + inAtIndex;
|
||||
T* loc = fBuffer + inAtIndex;
|
||||
memmove(loc + inNumItems, loc, (fItemCount - inAtIndex) * sizeof(T));
|
||||
memcpy(loc, inItem, delta);
|
||||
|
||||
@@ -116,7 +93,7 @@ _BTextViewSupportBuffer_<T>::RemoveItemsAt(int32 inNumItems,
|
||||
inAtIndex = (inAtIndex > fItemCount - 1) ? (fItemCount - 1) : inAtIndex;
|
||||
inAtIndex = (inAtIndex < 0) ? 0 : inAtIndex;
|
||||
|
||||
T *loc = fBuffer + inAtIndex;
|
||||
T* loc = fBuffer + inAtIndex;
|
||||
memmove(loc, loc + inNumItems,
|
||||
(fItemCount - (inNumItems + inAtIndex)) * sizeof(T));
|
||||
|
||||
@@ -125,7 +102,7 @@ _BTextViewSupportBuffer_<T>::RemoveItemsAt(int32 inNumItems,
|
||||
uint32 extraSize = fBufferCount - (logSize - delta);
|
||||
if (extraSize > (fExtraCount * sizeof(T))) {
|
||||
fBufferCount = (logSize - delta) + (fExtraCount * sizeof(T));
|
||||
fBuffer = (T *)realloc(fBuffer, fBufferCount);
|
||||
fBuffer = (T*)realloc(fBuffer, fBufferCount);
|
||||
if (fBuffer == NULL)
|
||||
debugger("RemoveItemsAt(): reallocation failed");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user