Automatic style cleanup with the astyle program.

This commit is contained in:
plfiorini 2010-07-10 13:58:15 +00:00
parent 082f2ad34e
commit a651de0f53
16 changed files with 2779 additions and 3014 deletions

View File

@ -10,20 +10,20 @@
#include "SmileTextRender.h"
//tmp
BMessage* faces=NULL;
bool valid=false;
bool fname=false;
bool svg=false;
bool size=true;
BMessage* faces = NULL;
bool valid = false;
bool fname = false;
bool svg = false;
bool size = true;
BString filename;
BString face;
BPath path;
BString gCharacters;
Emoconfig::Emoconfig(const char* xmlfile):BMessage()
Emoconfig::Emoconfig(const char* xmlfile): BMessage()
{
fEmoticonSize = 16.0; //default
numfaces=0;
numfaces = 0;
fParser = XML_ParserCreate(NULL);
@ -36,19 +36,18 @@ Emoconfig::Emoconfig(const char* xmlfile):BMessage()
p.GetParent(&path);
// loading the config file..
BFile* settings=new BFile(xmlfile,B_READ_ONLY);
BFile* settings = new BFile(xmlfile, B_READ_ONLY);
off_t size;
settings->GetSize(&size);
if(size)
{
void *buffer=malloc(size);
size=settings->Read(buffer,size);
if (size) {
void* buffer = malloc(size);
size = settings->Read(buffer, size);
XML_Parse(fParser, (const char*)buffer, size, true);
free(buffer);
}
delete settings;
if(fParser)
if (fParser)
XML_ParserFree(fParser);
printf("Emoconfig: loaded %d faces\n", numfaces);
@ -61,103 +60,80 @@ Emoconfig::~Emoconfig()
}
void
Emoconfig::StartElement(void * /*pUserData*/, const char * pName, const char ** /*pAttr*/)
Emoconfig::StartElement(void * /*pUserData*/, const char* pName, const char** /*pAttr*/)
{
//printf("StartElement %s\n",pName);
BString name(pName);
if(name.ICompare("emoticon")==0)
{
faces=new BMessage();
svg=false;
}
else
if(name.ICompare("text")==0 && faces)
{
valid=true;
}
else
if(name.ICompare("file")==0 && faces)
{
fname=true;
} else
if(name.ICompare("svg")==0 && faces)
{
// printf("File is SVG\n");
svg=true;
} else
if(name.ICompare("size")==0)
{
size=true;
if (name.ICompare("emoticon") == 0) {
faces = new BMessage();
svg = false;
} else if (name.ICompare("text") == 0 && faces) {
valid = true;
} else if (name.ICompare("file") == 0 && faces) {
fname = true;
} else if (name.ICompare("svg") == 0 && faces) {
// printf("File is SVG\n");
svg = true;
} else if (name.ICompare("size") == 0) {
size = true;
gCharacters = "";
}
}
void
Emoconfig::EndElement(void * pUserData, const char * pName)
Emoconfig::EndElement(void* pUserData, const char* pName)
{
//printf("EndElement %s\n",pName);
BString name(pName);
if(name.ICompare("emoticon")==0 && faces)
{
if (name.ICompare("emoticon") == 0 && faces) {
//faces->PrintToStream(); //debug
delete faces;
faces=NULL;
faces = NULL;
}
else
if(name.ICompare("text")==0 && faces)
{
valid=false;
faces->AddString("face",face);
} else if (name.ICompare("text") == 0 && faces) {
valid = false;
faces->AddString("face", face);
//printf("to ]%s[\n",face.String());
face.SetTo("");
}
else
if(name.ICompare("file")==0 && faces)
{
} else if (name.ICompare("file") == 0 && faces) {
//load file
//compose the filename
BPath p(path);
p.Append(filename.String());
BBitmap *icons = NULL;
BBitmap* icons = NULL;
if ( !svg )
{ //
icons=BTranslationUtils::GetBitmap(p.Path());
if ( !svg ) {
//
icons = BTranslationUtils::GetBitmap(p.Path());
}
//assign to faces;
fname=false;
fname = false;
// printf("Filename %s [%s]\n",p.Path(),path.Path());
if(!icons) return;
// printf("Filename %s [%s]\n",p.Path(),path.Path());
if (!icons) return;
int i=0;
int i = 0;
BString s;
while(faces->FindString("face",i,&s)==B_OK)
{
while (faces->FindString("face", i, &s) == B_OK) {
if(i==0)
{
((Emoconfig*)pUserData)->menu.AddPointer(s.String(),(const void*)icons);
((Emoconfig*)pUserData)->menu.AddString("face",s.String());
if (i == 0) {
((Emoconfig*)pUserData)->menu.AddPointer(s.String(), (const void*)icons);
((Emoconfig*)pUserData)->menu.AddString("face", s.String());
}
((BMessage*)pUserData)->AddPointer(s.String(),(const void*)icons);
((BMessage*)pUserData)->AddString("face",s.String());
((BMessage*)pUserData)->AddPointer(s.String(), (const void*)icons);
((BMessage*)pUserData)->AddString("face", s.String());
((Emoconfig*)pUserData)->numfaces++;
i++;
}
} else
if(name.ICompare("size")==0)
{
if ( size )
{
} else if (name.ICompare("size") == 0) {
if ( size ) {
((Emoconfig*)pUserData)->fEmoticonSize = atoi(gCharacters.String());
}
@ -167,26 +143,20 @@ Emoconfig::EndElement(void * pUserData, const char * pName)
}
void
Emoconfig::Characters(void * /*pUserData*/, const char * pString, int pLen)
Emoconfig::Characters(void * /*pUserData*/, const char* pString, int pLen)
{
BString f(pString,pLen);
BString f(pString, pLen);
//printf("Characters %s\n",f.String());
if(faces && valid)
{
if (faces && valid) {
f.RemoveAll(" ");
f.RemoveAll("\"");
if(f.Length()>0)
if (f.Length() > 0)
face.Append(f);
}
else
if(fname)
{
} else if (fname) {
f.RemoveAll(" ");
filename=f;
filename = f;
}
else
{
} else {
gCharacters.Append(f);
}
}

View File

@ -8,22 +8,24 @@
class Emoconfig : public BMessage
{
public:
public:
Emoconfig(const char* xmlfile);
~Emoconfig();
int numfaces;
BMessage menu;
float GetEmoticonSize() { return fEmoticonSize; }
float GetEmoticonSize() {
return fEmoticonSize;
}
private:
private:
float fEmoticonSize;
XML_Parser fParser;
static void StartElement(void * pUserData, const char * pName, const char ** pAttr);
static void EndElement(void * pUserData, const char * pName);
static void Characters(void * pUserData, const char * pString, int pLen);
static void StartElement(void* pUserData, const char* pName, const char** pAttr);
static void EndElement(void* pUserData, const char* pName);
static void Characters(void* pUserData, const char* pString, int pLen);
};

View File

@ -41,7 +41,7 @@ Emoticor::LoadConfig(const char* txt)
}
void
Emoticor::_findTokens(RunView *fTextView,BString text,int tokenstart, int16 cols ,int16 font ,int16 cols2 ,int16 font2)
Emoticor::_findTokens(RunView* fTextView, BString text, int tokenstart, int16 cols , int16 font , int16 cols2 , int16 font2)
{
//******************************************
// "Iteration is human, recursion is divine"
@ -52,65 +52,60 @@ Emoticor::_findTokens(RunView *fTextView,BString text,int tokenstart, int16 cols
BString cur;
int i = tokenstart;
if (fConfig != NULL)
{
while(fConfig->FindString("face",i,&cur)==B_OK)
if (fConfig != NULL) {
while (fConfig->FindString("face", i, &cur) == B_OK)
//for(int i=tokenstart;i<config->numfaces;i++)
{
i++;
//if(config->FindString("face",i,&cur)!=B_OK) return;
newindex=0;
newindex = 0;
while(true)
{
newindex=text.IFindFirst(cur.String(),0);
while (true) {
newindex = text.IFindFirst(cur.String(), 0);
//printf("Try %d %s -- match %d\n",i,cur->original.String(),newindex);
if(newindex!=B_ERROR)
{
if (newindex != B_ERROR) {
//take a walk on the left side ;)
//printf("Found at %ld \n",newindex);
if(newindex-1>=0)
{
if (newindex - 1 >= 0) {
BString left;
text.CopyInto(left,0,newindex);
text.CopyInto(left, 0, newindex);
//printf("ready to recourse! [%s]\n",left.String());
_findTokens(fTextView,left,tokenstart+1,cols,font,cols2,font2);
_findTokens(fTextView, left, tokenstart + 1, cols, font, cols2, font2);
}
text.Remove(0,newindex+cur.Length());
text.Remove(0, newindex + cur.Length());
//printf("remaning [%s] printed [%s]\n",text.String(),cur->original.String());
fTextView->Append(cur.String(),cols2,cols2,font2);
fTextView->Append(cur.String(), cols2, cols2, font2);
if(text.Length()==0) return; //useless stack
}
else
if (text.Length() == 0) return; //useless stack
} else
break;
}
}
}
fTextView->Append(text.String(),cols,cols,font);
fTextView->Append(text.String(), cols, cols, font);
}
void
Emoticor::AddText(RunView *fTextView,const char * txt, int16 cols ,int16 font ,int16 cols2 ,int16 font2 )
Emoticor::AddText(RunView* fTextView, const char* txt, int16 cols , int16 font , int16 cols2 , int16 font2 )
{
BString left(txt);
// if(!fConfig)
// fTextView->Append(txt,cols,cols,font);
// if(!fConfig)
// fTextView->Append(txt,cols,cols,font);
_findTokens(fTextView,left,0,cols,font,cols2,font2);
_findTokens(fTextView, left, 0, cols, font, cols2, font2);
return;

View File

@ -8,22 +8,22 @@
class Emoticor
{
public:
public:
static Emoticor* Get(); //singleton
void AddText(RunView *fTextView,const char* text, int16 cols ,int16 font ,int16 cols2 ,int16 font2 );
void AddText(RunView* fTextView, const char* text, int16 cols , int16 font , int16 cols2 , int16 font2 );
void LoadConfig(const char*);
Emoconfig *Config();
Emoconfig* Config();
~Emoticor();
private:
private:
Emoticor();
Emoconfig* fConfig;
void _findTokens(RunView *fTextView,BString text,int tokenstart, int16 cols ,int16 font ,int16 cols2 ,int16 font2);
void _findTokens(RunView* fTextView, BString text, int tokenstart, int16 cols , int16 font , int16 cols2 , int16 font2);
};

View File

@ -9,34 +9,37 @@
class NormalTextRender : public TextRender
{
public:
public:
NormalTextRender(BFont f):TextRender(){
font=f;
NormalTextRender(BFont f): TextRender() {
font = f;
}
virtual ~NormalTextRender() {};
virtual void Render(BView *target,const char* txt,int16 num,BPoint pos) {
virtual void Render(BView* target, const char* txt, int16 num, BPoint pos) {
target->SetFont(&font);
target->DrawString(txt,num,pos);
target->DrawString(txt, num, pos);
};
virtual float Size(){ return font.Size();}
virtual float Size() {
return font.Size();
}
virtual void GetHeight(font_height *height){ font.GetHeight(height); };
virtual void GetHeight(font_height* height) {
font.GetHeight(height);
};
virtual void
GetEscapements(const char charArray[], int32 numChars,float escapementArray[])
{
font.GetEscapements(charArray,numChars,escapementArray);
GetEscapements(const char charArray[], int32 numChars, float escapementArray[]) {
font.GetEscapements(charArray, numChars, escapementArray);
}
private:
private:
BFont font;
};

View File

@ -73,52 +73,55 @@ template<class T> class BObjectList;
template<class T>
struct UnaryPredicate {
virtual int operator()(const T *) const
virtual int operator()(const T*) const
// virtual could be avoided here if FindBinaryInsertionIndex,
// etc. were member template functions
{ return 0; }
{
return 0;
}
private:
static int _unary_predicate_glue(const void *item, void *context);
static int _unary_predicate_glue(const void* item, void* context);
friend class BObjectList<T>;
friend class BObjectList<T>;
};
template<class T>
int
UnaryPredicate<T>::_unary_predicate_glue(const void *item, void *context)
UnaryPredicate<T>::_unary_predicate_glue(const void* item, void* context)
{
return ((UnaryPredicate<T> *)context)->operator()((const T *)item);
return ((UnaryPredicate<T> *)context)->operator()((const T*)item);
}
class _PointerList_ : public BList {
class _PointerList_ : public BList
{
public:
_PointerList_(const _PointerList_ &list);
_PointerList_(int32 itemsPerBlock = 20, bool owning = false);
~_PointerList_();
typedef void *(* GenericEachFunction)(void *, void *);
typedef int (* GenericCompareFunction)(const void *, const void *);
typedef int (* GenericCompareFunctionWithState)(const void *, const void *,
void *);
typedef int (* UnaryPredicateGlue)(const void *, void *);
typedef void *(* GenericEachFunction)(void*, void*);
typedef int (* GenericCompareFunction)(const void*, const void*);
typedef int (* GenericCompareFunctionWithState)(const void*, const void*,
void*);
typedef int (* UnaryPredicateGlue)(const void*, void*);
void *EachElement(GenericEachFunction, void *);
void* EachElement(GenericEachFunction, void*);
void SortItems(GenericCompareFunction);
void SortItems(GenericCompareFunctionWithState, void *state);
void SortItems(GenericCompareFunctionWithState, void* state);
void HSortItems(GenericCompareFunction);
void HSortItems(GenericCompareFunctionWithState, void *state);
void HSortItems(GenericCompareFunctionWithState, void* state);
void *BinarySearch(const void *, GenericCompareFunction) const;
void *BinarySearch(const void *, GenericCompareFunctionWithState, void *state) const;
void* BinarySearch(const void*, GenericCompareFunction) const;
void* BinarySearch(const void*, GenericCompareFunctionWithState, void* state) const;
int32 BinarySearchIndex(const void *, GenericCompareFunction) const;
int32 BinarySearchIndex(const void *, GenericCompareFunctionWithState, void *state) const;
int32 BinarySearchIndexByPredicate(const void *, UnaryPredicateGlue) const;
int32 BinarySearchIndex(const void*, GenericCompareFunction) const;
int32 BinarySearchIndex(const void*, GenericCompareFunctionWithState, void* state) const;
int32 BinarySearchIndexByPredicate(const void*, UnaryPredicateGlue) const;
bool Owning() const;
bool ReplaceItem(int32, void *);
bool ReplaceItem(int32, void*);
protected:
bool owning;
@ -126,124 +129,127 @@ protected:
};
template<class T>
class BObjectList : private _PointerList_ {
class BObjectList : private _PointerList_
{
public:
// iteration and sorting
typedef T *(* EachFunction)(T *, void *);
typedef const T *(* ConstEachFunction)(const T *, void *);
typedef int (* CompareFunction)(const T *, const T *);
typedef int (* CompareFunctionWithState)(const T *, const T *, void *state);
typedef T *(* EachFunction)(T*, void*);
typedef const T *(* ConstEachFunction)(const T*, void*);
typedef int (* CompareFunction)(const T*, const T*);
typedef int (* CompareFunctionWithState)(const T*, const T*, void* state);
BObjectList(int32 itemsPerBlock = 20, bool owning = false);
BObjectList(const BObjectList &list);
BObjectList(const BObjectList& list);
// clones list; if list is owning, makes copies of all
// the items
virtual ~BObjectList();
BObjectList &operator=(const BObjectList &list);
BObjectList& operator=(const BObjectList& list);
// clones list; if list is owning, makes copies of all
// the items
// adding and removing
// ToDo:
// change Add calls to return const item
bool AddItem(T *);
bool AddItem(T *, int32);
bool AddList(BObjectList *);
bool AddList(BObjectList *, int32);
bool AddItem(T*);
bool AddItem(T*, int32);
bool AddList(BObjectList*);
bool AddList(BObjectList*, int32);
bool RemoveItem(T *, bool deleteIfOwning = true);
bool RemoveItem(T*, bool deleteIfOwning = true);
// if owning, deletes the removed item
T *RemoveItemAt(int32);
T* RemoveItemAt(int32);
// returns the removed item
void MakeEmpty();
// item access
T *ItemAt(int32) const;
T* ItemAt(int32) const;
bool ReplaceItem(int32 index, T *);
bool ReplaceItem(int32 index, T*);
// if list is owning, deletes the item at <index> first
T *SwapWithItem(int32 index, T *newItem);
T* SwapWithItem(int32 index, T* newItem);
// same as ReplaceItem, except does not delete old item at <index>,
// returns it instead
T *FirstItem() const;
T *LastItem() const;
T* FirstItem() const;
T* LastItem() const;
// misc. getters
int32 IndexOf(const T *) const;
bool HasItem(const T *) const;
int32 IndexOf(const T*) const;
bool HasItem(const T*) const;
bool IsEmpty() const;
int32 CountItems() const;
T *EachElement(EachFunction, void *);
const T *EachElement(ConstEachFunction, void *) const;
T* EachElement(EachFunction, void*);
const T* EachElement(ConstEachFunction, void*) const;
void SortItems(CompareFunction);
void SortItems(CompareFunctionWithState, void *state);
void SortItems(CompareFunctionWithState, void* state);
void HSortItems(CompareFunction);
void HSortItems(CompareFunctionWithState, void *state);
void HSortItems(CompareFunctionWithState, void* state);
// linear search, returns first item that matches predicate
const T *FindIf(const UnaryPredicate<T> &) const;
T *FindIf(const UnaryPredicate<T> &);
const T* FindIf(const UnaryPredicate<T> &) const;
T* FindIf(const UnaryPredicate<T> &);
// list must be sorted with CompareFunction for these to work
T *BinarySearch(const T &, CompareFunction) const;
T *BinarySearch(const T &, CompareFunctionWithState, void *state) const;
T* BinarySearch(const T&, CompareFunction) const;
T* BinarySearch(const T&, CompareFunctionWithState, void* state) const;
template<typename Key>
T *BinarySearchByKey(const Key &key, int (*compare)(const Key *, const T *))
T* BinarySearchByKey(const Key& key, int (*compare)(const Key*, const T*))
const;
template<typename Key>
T *BinarySearchByKey(const Key &key,
int (*compare)(const Key *, const T *, void *), void *state) const;
T* BinarySearchByKey(const Key& key,
int (*compare)(const Key*, const T*, void*), void* state) const;
int32 BinarySearchIndex(const T &item, CompareFunction compare) const;
int32 BinarySearchIndex(const T &item, CompareFunctionWithState compare,
void *state) const;
int32 BinarySearchIndex(const T& item, CompareFunction compare) const;
int32 BinarySearchIndex(const T& item, CompareFunctionWithState compare,
void* state) const;
template<typename Key>
int32 BinarySearchIndexByKey(const Key &key,
int (*compare)(const Key *, const T *)) const;
int32 BinarySearchIndexByKey(const Key& key,
int (*compare)(const Key*, const T*)) const;
// Binary insertion - list must be sorted with CompareFunction for
// these to work
// simple insert
bool BinaryInsert(T *, CompareFunction);
bool BinaryInsert(T *, CompareFunctionWithState, void *state);
bool BinaryInsert(T *, const UnaryPredicate<T> &);
bool BinaryInsert(T*, CompareFunction);
bool BinaryInsert(T*, CompareFunctionWithState, void* state);
bool BinaryInsert(T*, const UnaryPredicate<T> &);
// unique insert, returns false if item already in list
bool BinaryInsertUnique(T *, CompareFunction);
bool BinaryInsertUnique(T *, CompareFunctionWithState, void *state);
bool BinaryInsertUnique(T *, const UnaryPredicate<T> &);
bool BinaryInsertUnique(T*, CompareFunction);
bool BinaryInsertUnique(T*, CompareFunctionWithState, void* state);
bool BinaryInsertUnique(T*, const UnaryPredicate<T> &);
// insert a copy of the item, returns new inserted item
T *BinaryInsertCopy(const T &copyThis, CompareFunction);
T *BinaryInsertCopy(const T &copyThis, CompareFunctionWithState, void *state);
T* BinaryInsertCopy(const T& copyThis, CompareFunction);
T* BinaryInsertCopy(const T& copyThis, CompareFunctionWithState, void* state);
// insert a copy of the item if not in list already
// returns new inserted item or existing item in case of a conflict
T *BinaryInsertCopyUnique(const T &copyThis, CompareFunction);
T *BinaryInsertCopyUnique(const T &copyThis, CompareFunctionWithState, void *state);
T* BinaryInsertCopyUnique(const T& copyThis, CompareFunction);
T* BinaryInsertCopyUnique(const T& copyThis, CompareFunctionWithState, void* state);
int32 FindBinaryInsertionIndex(const UnaryPredicate<T> &, bool *alreadyInList = 0) const;
int32 FindBinaryInsertionIndex(const UnaryPredicate<T> &, bool* alreadyInList = 0) const;
// returns either the index into which a new item should be inserted
// or index of an existing item that matches the predicate
// deprecated API, will go away
BList *AsBList()
{ return this; }
const BList *AsBList() const
{ return this; }
BList* AsBList() {
return this;
}
const BList* AsBList() const {
return this;
}
private:
void SetItem(int32, T *);
void SetItem(int32, T*);
};
template<class Item, class Result, class Param1>
@ -262,7 +268,7 @@ WhileEachListItem(BObjectList<Item> *list, Result (Item::*func)(Param1), Param1
template<class Item, class Result, class Param1>
Result
WhileEachListItem(BObjectList<Item> *list, Result (*func)(Item *, Param1), Param1 p1)
WhileEachListItem(BObjectList<Item> *list, Result (*func)(Item*, Param1), Param1 p1)
{
Result result = 0;
int32 count = list->CountItems();
@ -291,7 +297,7 @@ WhileEachListItem(BObjectList<Item> *list, Result (Item::*func)(Param1, Param2),
template<class Item, class Result, class Param1, class Param2>
Result
WhileEachListItem(BObjectList<Item> *list, Result (*func)(Item *, Param1, Param2),
WhileEachListItem(BObjectList<Item> *list, Result (*func)(Item*, Param1, Param2),
Param1 p1, Param2 p2)
{
Result result = 0;
@ -306,7 +312,7 @@ WhileEachListItem(BObjectList<Item> *list, Result (*func)(Item *, Param1, Param2
template<class Item, class Result, class Param1, class Param2, class Param3, class Param4>
Result
WhileEachListItem(BObjectList<Item> *list, Result (*func)(Item *, Param1, Param2,
WhileEachListItem(BObjectList<Item> *list, Result (*func)(Item*, Param1, Param2,
Param3, Param4), Param1 p1, Param2 p2, Param3 p3, Param4 p4)
{
Result result = 0;
@ -330,7 +336,7 @@ EachListItemIgnoreResult(BObjectList<Item> *list, Result (Item::*func)())
template<class Item, class Param1>
void
EachListItem(BObjectList<Item> *list, void (*func)(Item *, Param1), Param1 p1)
EachListItem(BObjectList<Item> *list, void (*func)(Item*, Param1), Param1 p1)
{
int32 count = list->CountItems();
for (int32 index = 0; index < count; index++)
@ -349,7 +355,7 @@ EachListItem(BObjectList<Item> *list, void (Item::*func)(Param1, Param2),
template<class Item, class Param1, class Param2>
void
EachListItem(BObjectList<Item> *list, void (*func)(Item *,Param1, Param2),
EachListItem(BObjectList<Item> *list, void (*func)(Item*, Param1, Param2),
Param1 p1, Param2 p2)
{
int32 count = list->CountItems();
@ -359,7 +365,7 @@ EachListItem(BObjectList<Item> *list, void (*func)(Item *,Param1, Param2),
template<class Item, class Param1, class Param2, class Param3>
void
EachListItem(BObjectList<Item> *list, void (*func)(Item *,Param1, Param2,
EachListItem(BObjectList<Item> *list, void (*func)(Item*, Param1, Param2,
Param3), Param1 p1, Param2 p2, Param3 p3)
{
int32 count = list->CountItems();
@ -370,7 +376,7 @@ EachListItem(BObjectList<Item> *list, void (*func)(Item *,Param1, Param2,
template<class Item, class Param1, class Param2, class Param3, class Param4>
void
EachListItem(BObjectList<Item> *list, void (*func)(Item *,Param1, Param2,
EachListItem(BObjectList<Item> *list, void (*func)(Item*, Param1, Param2,
Param3, Param4), Param1 p1, Param2 p2, Param3 p3, Param4 p4)
{
int32 count = list->CountItems();
@ -401,7 +407,7 @@ BObjectList<T>::BObjectList(const BObjectList<T> &list)
// make our own copies in an owning list
int32 count = list.CountItems();
for (int32 index = 0; index < count; index++) {
T *item = list.ItemAt(index);
T* item = list.ItemAt(index);
if (item)
item = new T(*item);
SetItem(index, item);
@ -427,7 +433,7 @@ BObjectList<T>::operator=(const BObjectList<T> &list)
// make our own copies in an owning list
int32 count = list.CountItems();
for (int32 index = 0; index < count; index++) {
T *item = list.ItemAt(index);
T* item = list.ItemAt(index);
if (item)
item = new T(*item);
SetItem(index, item);
@ -438,17 +444,17 @@ BObjectList<T>::operator=(const BObjectList<T> &list)
template<class T>
bool
BObjectList<T>::AddItem(T *item)
BObjectList<T>::AddItem(T* item)
{
// need to cast to void * to make T work for const pointers
return _PointerList_::AddItem((void *)item);
return _PointerList_::AddItem((void*)item);
}
template<class T>
bool
BObjectList<T>::AddItem(T *item, int32 atIndex)
BObjectList<T>::AddItem(T* item, int32 atIndex)
{
return _PointerList_::AddItem((void *)item, atIndex);
return _PointerList_::AddItem((void*)item, atIndex);
}
template<class T>
@ -468,9 +474,9 @@ BObjectList<T>::AddList(BObjectList<T> *newItems, int32 atIndex)
template<class T>
bool
BObjectList<T>::RemoveItem(T *item, bool deleteIfOwning)
BObjectList<T>::RemoveItem(T* item, bool deleteIfOwning)
{
bool result = _PointerList_::RemoveItem((void *)item);
bool result = _PointerList_::RemoveItem((void*)item);
if (result && Owning() && deleteIfOwning)
delete item;
@ -482,67 +488,67 @@ template<class T>
T *
BObjectList<T>::RemoveItemAt(int32 index)
{
return (T *)_PointerList_::RemoveItem(index);
return (T*)_PointerList_::RemoveItem(index);
}
template<class T>
inline T *
BObjectList<T>::ItemAt(int32 index) const
{
return (T *)_PointerList_::ItemAt(index);
return (T*)_PointerList_::ItemAt(index);
}
template<class T>
bool
BObjectList<T>::ReplaceItem(int32 index, T *item)
BObjectList<T>::ReplaceItem(int32 index, T* item)
{
if (owning)
delete ItemAt(index);
return _PointerList_::ReplaceItem(index, (void *)item);
return _PointerList_::ReplaceItem(index, (void*)item);
}
template<class T>
T *
BObjectList<T>::SwapWithItem(int32 index, T *newItem)
BObjectList<T>::SwapWithItem(int32 index, T* newItem)
{
T *result = ItemAt(index);
_PointerList_::ReplaceItem(index, (void *)newItem);
T* result = ItemAt(index);
_PointerList_::ReplaceItem(index, (void*)newItem);
return result;
}
template<class T>
void
BObjectList<T>::SetItem(int32 index, T *newItem)
BObjectList<T>::SetItem(int32 index, T* newItem)
{
_PointerList_::ReplaceItem(index, (void *)newItem);
_PointerList_::ReplaceItem(index, (void*)newItem);
}
template<class T>
int32
BObjectList<T>::IndexOf(const T *item) const
BObjectList<T>::IndexOf(const T* item) const
{
return _PointerList_::IndexOf((void *)item);
return _PointerList_::IndexOf((void*)item);
}
template<class T>
T *
BObjectList<T>::FirstItem() const
{
return (T *)_PointerList_::FirstItem();
return (T*)_PointerList_::FirstItem();
}
template<class T>
T *
BObjectList<T>::LastItem() const
{
return (T *)_PointerList_::LastItem();
return (T*)_PointerList_::LastItem();
}
template<class T>
bool
BObjectList<T>::HasItem(const T *item) const
BObjectList<T>::HasItem(const T* item) const
{
return _PointerList_::HasItem((void *)item);
return _PointerList_::HasItem((void*)item);
}
template<class T>
@ -573,17 +579,17 @@ BObjectList<T>::MakeEmpty()
template<class T>
T *
BObjectList<T>::EachElement(EachFunction func, void *params)
BObjectList<T>::EachElement(EachFunction func, void* params)
{
return (T *)_PointerList_::EachElement((GenericEachFunction)func, params);
return (T*)_PointerList_::EachElement((GenericEachFunction)func, params);
}
template<class T>
const T *
BObjectList<T>::EachElement(ConstEachFunction func, void *params) const
BObjectList<T>::EachElement(ConstEachFunction func, void* params) const
{
return (const T *)
return (const T*)
const_cast<BObjectList<T> *>(this)->_PointerList_::EachElement(
(GenericEachFunction)func, params);
}
@ -620,7 +626,7 @@ BObjectList<T>::SortItems(CompareFunction function)
template<class T>
void
BObjectList<T>::SortItems(CompareFunctionWithState function, void *state)
BObjectList<T>::SortItems(CompareFunctionWithState function, void* state)
{
_PointerList_::SortItems((GenericCompareFunctionWithState)function, state);
}
@ -634,14 +640,14 @@ BObjectList<T>::HSortItems(CompareFunction function)
template<class T>
void
BObjectList<T>::HSortItems(CompareFunctionWithState function, void *state)
BObjectList<T>::HSortItems(CompareFunctionWithState function, void* state)
{
_PointerList_::HSortItems((GenericCompareFunctionWithState)function, state);
}
template<class T>
T *
BObjectList<T>::BinarySearch(const T &key, CompareFunction func) const
BObjectList<T>::BinarySearch(const T& key, CompareFunction func) const
{
return (T*)_PointerList_::BinarySearch(&key,
(GenericCompareFunction)func);
@ -649,7 +655,7 @@ BObjectList<T>::BinarySearch(const T &key, CompareFunction func) const
template<class T>
T *
BObjectList<T>::BinarySearch(const T &key, CompareFunctionWithState func, void *state) const
BObjectList<T>::BinarySearch(const T& key, CompareFunctionWithState func, void* state) const
{
return (T*)_PointerList_::BinarySearch(&key,
(GenericCompareFunctionWithState)func, state);
@ -659,8 +665,8 @@ BObjectList<T>::BinarySearch(const T &key, CompareFunctionWithState func, void *
template<class T>
template<typename Key>
T *
BObjectList<T>::BinarySearchByKey(const Key &key,
int (*compare)(const Key *, const T *)) const
BObjectList<T>::BinarySearchByKey(const Key& key,
int (*compare)(const Key*, const T*)) const
{
return (T*)_PointerList_::BinarySearch(&key,
(GenericCompareFunction)compare);
@ -670,8 +676,8 @@ BObjectList<T>::BinarySearchByKey(const Key &key,
template<class T>
template<typename Key>
T *
BObjectList<T>::BinarySearchByKey(const Key &key,
int (*compare)(const Key *, const T *, void *), void *state) const
BObjectList<T>::BinarySearchByKey(const Key& key,
int (*compare)(const Key*, const T*, void*), void* state) const
{
return (T*)_PointerList_::BinarySearch(&key,
(GenericCompareFunctionWithState)compare, state);
@ -680,7 +686,7 @@ BObjectList<T>::BinarySearchByKey(const Key &key,
template<class T>
int32
BObjectList<T>::BinarySearchIndex(const T &item, CompareFunction compare) const
BObjectList<T>::BinarySearchIndex(const T& item, CompareFunction compare) const
{
return _PointerList_::BinarySearchIndex(&item,
(GenericCompareFunction)compare);
@ -689,8 +695,8 @@ BObjectList<T>::BinarySearchIndex(const T &item, CompareFunction compare) const
template<class T>
int32
BObjectList<T>::BinarySearchIndex(const T &item,
CompareFunctionWithState compare, void *state) const
BObjectList<T>::BinarySearchIndex(const T& item,
CompareFunctionWithState compare, void* state) const
{
return _PointerList_::BinarySearchIndex(&item,
(GenericCompareFunctionWithState)compare, state);
@ -700,8 +706,8 @@ BObjectList<T>::BinarySearchIndex(const T &item,
template<class T>
template<typename Key>
int32
BObjectList<T>::BinarySearchIndexByKey(const Key &key,
int (*compare)(const Key *, const T *)) const
BObjectList<T>::BinarySearchIndexByKey(const Key& key,
int (*compare)(const Key*, const T*)) const
{
return _PointerList_::BinarySearchIndex(&key,
(GenericCompareFunction)compare);
@ -710,7 +716,7 @@ BObjectList<T>::BinarySearchIndexByKey(const Key &key,
template<class T>
bool
BObjectList<T>::BinaryInsert(T *item, CompareFunction func)
BObjectList<T>::BinaryInsert(T* item, CompareFunction func)
{
int32 index = _PointerList_::BinarySearchIndex(item,
(GenericCompareFunction)func);
@ -724,7 +730,7 @@ BObjectList<T>::BinaryInsert(T *item, CompareFunction func)
template<class T>
bool
BObjectList<T>::BinaryInsert(T *item, CompareFunctionWithState func, void *state)
BObjectList<T>::BinaryInsert(T* item, CompareFunctionWithState func, void* state)
{
int32 index = _PointerList_::BinarySearchIndex(item,
(GenericCompareFunctionWithState)func, state);
@ -738,7 +744,7 @@ BObjectList<T>::BinaryInsert(T *item, CompareFunctionWithState func, void *state
template<class T>
bool
BObjectList<T>::BinaryInsertUnique(T *item, CompareFunction func)
BObjectList<T>::BinaryInsertUnique(T* item, CompareFunction func)
{
int32 index = _PointerList_::BinarySearchIndex(item,
(GenericCompareFunction)func);
@ -750,7 +756,7 @@ BObjectList<T>::BinaryInsertUnique(T *item, CompareFunction func)
template<class T>
bool
BObjectList<T>::BinaryInsertUnique(T *item, CompareFunctionWithState func, void *state)
BObjectList<T>::BinaryInsertUnique(T* item, CompareFunctionWithState func, void* state)
{
int32 index = _PointerList_::BinarySearchIndex(item,
(GenericCompareFunctionWithState)func, state);
@ -763,7 +769,7 @@ BObjectList<T>::BinaryInsertUnique(T *item, CompareFunctionWithState func, void
template<class T>
T *
BObjectList<T>::BinaryInsertCopy(const T &copyThis, CompareFunction func)
BObjectList<T>::BinaryInsertCopy(const T& copyThis, CompareFunction func)
{
int32 index = _PointerList_::BinarySearchIndex(&copyThis,
(GenericCompareFunction)func);
@ -773,14 +779,14 @@ BObjectList<T>::BinaryInsertCopy(const T &copyThis, CompareFunction func)
else
index = -index - 1;
T *newItem = new T(copyThis);
T* newItem = new T(copyThis);
AddItem(newItem, index);
return newItem;
}
template<class T>
T *
BObjectList<T>::BinaryInsertCopy(const T &copyThis, CompareFunctionWithState func, void *state)
BObjectList<T>::BinaryInsertCopy(const T& copyThis, CompareFunctionWithState func, void* state)
{
int32 index = _PointerList_::BinarySearchIndex(&copyThis,
(GenericCompareFunctionWithState)func, state);
@ -790,14 +796,14 @@ BObjectList<T>::BinaryInsertCopy(const T &copyThis, CompareFunctionWithState fun
else
index = -index - 1;
T *newItem = new T(copyThis);
T* newItem = new T(copyThis);
AddItem(newItem, index);
return newItem;
}
template<class T>
T *
BObjectList<T>::BinaryInsertCopyUnique(const T &copyThis, CompareFunction func)
BObjectList<T>::BinaryInsertCopyUnique(const T& copyThis, CompareFunction func)
{
int32 index = _PointerList_::BinarySearchIndex(&copyThis,
(GenericCompareFunction)func);
@ -805,15 +811,15 @@ BObjectList<T>::BinaryInsertCopyUnique(const T &copyThis, CompareFunction func)
return ItemAt(index);
index = -index - 1;
T *newItem = new T(copyThis);
T* newItem = new T(copyThis);
AddItem(newItem, index);
return newItem;
}
template<class T>
T *
BObjectList<T>::BinaryInsertCopyUnique(const T &copyThis, CompareFunctionWithState func,
void *state)
BObjectList<T>::BinaryInsertCopyUnique(const T& copyThis, CompareFunctionWithState func,
void* state)
{
int32 index = _PointerList_::BinarySearchIndex(&copyThis,
(GenericCompareFunctionWithState)func, state);
@ -821,15 +827,15 @@ BObjectList<T>::BinaryInsertCopyUnique(const T &copyThis, CompareFunctionWithSta
return ItemAt(index);
index = -index - 1;
T *newItem = new T(copyThis);
T* newItem = new T(copyThis);
AddItem(newItem, index);
return newItem;
}
template<class T>
int32
BObjectList<T>::FindBinaryInsertionIndex(const UnaryPredicate<T> &pred, bool *alreadyInList)
const
BObjectList<T>::FindBinaryInsertionIndex(const UnaryPredicate<T> &pred, bool* alreadyInList)
const
{
int32 index = _PointerList_::BinarySearchIndexByPredicate(&pred,
(UnaryPredicateGlue)&UnaryPredicate<T>::_unary_predicate_glue);
@ -845,14 +851,14 @@ BObjectList<T>::FindBinaryInsertionIndex(const UnaryPredicate<T> &pred, bool *al
template<class T>
bool
BObjectList<T>::BinaryInsert(T *item, const UnaryPredicate<T> &pred)
BObjectList<T>::BinaryInsert(T* item, const UnaryPredicate<T> &pred)
{
return AddItem(item, FindBinaryInsertionIndex(pred));
}
template<class T>
bool
BObjectList<T>::BinaryInsertUnique(T *item, const UnaryPredicate<T> &pred)
BObjectList<T>::BinaryInsertUnique(T* item, const UnaryPredicate<T> &pred)
{
bool alreadyInList;
int32 index = FindBinaryInsertionIndex(pred, &alreadyInList);

File diff suppressed because it is too large Load Diff

View File

@ -50,7 +50,7 @@ class BPopUpMenu;
class SelectPos
{
public:
public:
int16 fLine;
int16 fOffset;
@ -62,7 +62,7 @@ class SelectPos
fOffset (selOffset)
{ }
SelectPos (const SelectPos &pos)
SelectPos (const SelectPos& pos)
: fLine (pos.fLine),
fOffset (pos.fOffset)
{ }
@ -70,21 +70,18 @@ class SelectPos
~SelectPos (void)
{ }
SelectPos &operator = (const SelectPos &pos)
{
SelectPos& operator = (const SelectPos& pos) {
fLine = pos.fLine;
fOffset = pos.fOffset;
return *this;
}
inline int operator == (const SelectPos &rhs) const
{
inline int operator == (const SelectPos& rhs) const {
return ((fLine == rhs.fLine) && (fOffset == rhs.fOffset));
}
inline int operator != (const SelectPos &rhs) const
{
inline int operator != (const SelectPos& rhs) const {
return (!(*this == rhs));
}
@ -93,28 +90,28 @@ class SelectPos
class RunView : public BView
{
BScrollView *fScroller;
BCursor *fURLCursor;
Theme *fTheme;
BScrollView* fScroller;
BCursor* fURLCursor;
Theme* fTheme;
Line *fWorking;
Line *fLines[LINE_COUNT];
Line* fWorking;
Line* fLines[LINE_COUNT];
int16 fLine_count,
fClickCount;
char *fStamp_format;
char *fClipping_name;
char* fStamp_format;
char* fClipping_name;
SelectPos fSp_start, fSp_end;
int32 fTracking;
SelectPos fTrack_offset;
BMessageRunner *fOff_view_runner;
BMessageRunner* fOff_view_runner;
bigtime_t fOff_view_time;
bool fResizedirty;
bool fFontsdirty;
BPopUpMenu *fMyPopUp;
BPopUpMenu* fMyPopUp;
BPoint fLastClick;
bigtime_t fLastClickTime;
@ -127,15 +124,15 @@ class RunView : public BView
void CheckURLCursor (BPoint);
void BuildPopUp (void);
bool CheckClickBounds (const SelectPos &, const BPoint &) const;
void LoadURL(const char *url);
bool CheckClickBounds (const SelectPos&, const BPoint&) const;
void LoadURL(const char* url);
public:
public:
RunView (
BRect,
const char *,
Theme *,
const char*,
Theme*,
uint32 = B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 = 0UL);
virtual ~RunView (void);
@ -143,42 +140,44 @@ class RunView : public BView
virtual void AttachedToWindow (void);
virtual void DetachedFromWindow (void);
virtual void FrameResized (float, float);
virtual void TargetedByScrollView (BScrollView *);
virtual void TargetedByScrollView (BScrollView*);
virtual void Show ();
virtual void Draw (BRect);
virtual void MessageReceived (BMessage *);
virtual void MessageReceived (BMessage*);
virtual void SetViewColor (rgb_color);
void SetViewColor (uchar red, uchar green, uchar blue, uchar alpha = 255)
{ rgb_color color = {red, green, blue, alpha}; SetViewColor (color); }
void SetViewColor (uchar red, uchar green, uchar blue, uchar alpha = 255) {
rgb_color color = {red, green, blue, alpha};
SetViewColor (color);
}
virtual void MouseDown (BPoint);
virtual void MouseMoved (BPoint, uint32, const BMessage *);
virtual void MouseMoved (BPoint, uint32, const BMessage*);
virtual void MouseUp (BPoint);
void Append (const char *, int32, int16, int16, int16);
void Append (const char *, int16, int16, int16);
void Append (const char*, int32, int16, int16, int16);
void Append (const char*, int16, int16, int16);
void Clear (void);
int16 LineCount (void) const;
const char *LineAt (int16) const;
const char* LineAt (int16) const;
void SetTimeStampFormat (const char *);
void SetTheme (Theme *);
void SetTimeStampFormat (const char*);
void SetTheme (Theme*);
SelectPos PositionAt (BPoint) const;
BPoint PointAt (SelectPos) const;
BRect GetTextFrame (const SelectPos &, const SelectPos &) const;
bool IntersectSelection (const SelectPos &, const SelectPos &) const;
void GetSelectionText (BString &) const;
void Select (const SelectPos &, const SelectPos &);
BRect GetTextFrame (const SelectPos&, const SelectPos&) const;
bool IntersectSelection (const SelectPos&, const SelectPos&) const;
void GetSelectionText (BString&) const;
void Select (const SelectPos&, const SelectPos&);
void SelectAll (void);
void SetClippingName (const char *);
bool FindText(const char *);
void SetClippingName (const char*);
bool FindText(const char*);
void ScrollToBottom(void);
void ScrollToSelection(void);

View File

@ -14,40 +14,39 @@
class SmileTextRender : public TextRender
{
public:
public:
SmileTextRender():TextRender(){};
SmileTextRender(): TextRender() {};
virtual ~SmileTextRender() {};
virtual void Render(BView *target,const char* txt,int16 num,BPoint pos) {
virtual void Render(BView* target, const char* txt, int16 num, BPoint pos) {
BBitmap *pointer=NULL;
BString f(txt,num);
BBitmap* pointer = NULL;
BString f(txt, num);
if(Emoticor::Get()->Config()->FindPointer(f.String(),(void**)&pointer)==B_OK)
{
if (Emoticor::Get()->Config()->FindPointer(f.String(), (void**)&pointer) == B_OK) {
target->SetDrawingMode( B_OP_ALPHA );
target->DrawBitmapAsync( pointer,BPoint(pos.x, pos.y- (Emoticor::Get()->Config()->GetEmoticonSize()/2)) );
target->DrawBitmapAsync( pointer, BPoint(pos.x, pos.y - (Emoticor::Get()->Config()->GetEmoticonSize() / 2)) );
target->SetDrawingMode( B_OP_OVER );
}
};
virtual float Size(){ return Emoticor::Get()->Config()->GetEmoticonSize();}
virtual float Size() {
return Emoticor::Get()->Config()->GetEmoticonSize();
}
virtual void GetHeight(font_height *h)
{
h->descent = h->ascent = Emoticor::Get()->Config()->GetEmoticonSize()/2;
h->leading=0;
virtual void GetHeight(font_height* h) {
h->descent = h->ascent = Emoticor::Get()->Config()->GetEmoticonSize() / 2;
h->leading = 0;
};
virtual void
GetEscapements(const char * /*charArray*/, int32 numChars,float escapementArray[])
{
GetEscapements(const char * /*charArray*/, int32 numChars, float escapementArray[]) {
//font.GetEscapements(charArray,numChars,escapementArray);
escapementArray[0]=1;
for(int i=1;i<numChars;i++) escapementArray[i]=0;
escapementArray[0] = 1;
for (int i = 1; i < numChars; i++) escapementArray[i] = 0;
}
};
#endif

View File

@ -5,13 +5,13 @@
class TextRender
{
public:
TextRender(){};
public:
TextRender() {};
virtual ~TextRender() {};
virtual void Render(BView *target,const char*,int16 num,BPoint pos) = 0;
virtual void GetHeight(font_height *height) = 0;
virtual void GetEscapements(const char charArray[], int32 numChars,float escapementArray[])=0;
virtual void Render(BView* target, const char*, int16 num, BPoint pos) = 0;
virtual void GetHeight(font_height* height) = 0;
virtual void GetEscapements(const char charArray[], int32 numChars, float escapementArray[]) = 0;
virtual float Size() = 0;
//

View File

@ -48,7 +48,7 @@ int16 Theme::SelectionBack = 3;
Theme::Theme (
const char *n,
const char* n,
int16 foreCount,
int16 backCount,
int16 renderCount)
@ -71,8 +71,8 @@ Theme::Theme (
normal_textrender = new NormalTextRender(be_plain_font);
text_renders = (TextRender**)malloc(render_count*sizeof(TextRender*));
for ( int i=0; i<render_count; i++ )
text_renders = (TextRender**)malloc(render_count * sizeof(TextRender*));
for ( int i = 0; i < render_count; i++ )
text_renders[i] = normal_textrender;
@ -100,9 +100,9 @@ Theme::~Theme (void)
delete_sem (sid);
//delete [] fonts;
for ( int i=0; i<render_count; i++ )
for ( int i = 0; i < render_count; i++ )
if ( text_renders[i] )
text_renders[i]=NULL;
text_renders[i] = NULL;
delete normal_textrender;
@ -195,11 +195,11 @@ Theme::FontAt (int16 which) const
TextRender*
Theme::TextRenderAt (int16 which)
{
if ( which < 0 ){
if ( which < 0 ) {
//printf("Theme::TextRenderAt(): which < 0 (%d)\n", which);
return normal_textrender;
}
if ( which >= render_count ){
if ( which >= render_count ) {
//printf("Theme::TextRenderAt(): which >= render_count (%d, %d)\n", which, render_count);
return normal_textrender;
}
@ -229,7 +229,7 @@ Theme::SetBackground (int16 which, const rgb_color color)
bool
Theme::SetTextRender(int16 which,TextRender *trender)
Theme::SetTextRender(int16 which, TextRender* trender)
{
@ -241,13 +241,13 @@ Theme::SetTextRender(int16 which,TextRender *trender)
}
void
Theme::AddView (BView *view)
Theme::AddView (BView* view)
{
list.AddItem (view);
}
void
Theme::RemoveView (BView *view)
Theme::RemoveView (BView* view)
{
list.RemoveItem (view);
}

View File

@ -37,10 +37,10 @@ class NormalTextRender;
class Theme
{
char *name;
rgb_color *fores;
rgb_color *backs;
TextRender **text_renders; //FIX!!
char* name;
rgb_color* fores;
rgb_color* backs;
TextRender** text_renders; //FIX!!
int16 fore_count;
int16 back_count;
@ -53,7 +53,7 @@ class Theme
float fTextMargin;
NormalTextRender* normal_textrender;
public:
public:
static int16 TimestampFore;
static int16 TimestampBack;
@ -67,14 +67,15 @@ class Theme
static int16 SelectionBack;
Theme (
const char *,
const char*,
int16,
int16,
int16);
virtual ~Theme (void);
const char *Name (void) const
{ return name; }
const char* Name (void) const {
return name;
}
void ReadLock (void);
void ReadUnlock (void);
@ -83,7 +84,7 @@ class Theme
int16 CountForegrounds (void) const;
int16 CountBackgrounds (void) const;
// int16 CountFonts (void) const;
// int16 CountFonts (void) const;
int16 CountTextRenders (void) const;
const rgb_color ForegroundAt (int16) const;
@ -94,25 +95,33 @@ class Theme
TextRender* TextRenderAt(int16);
bool SetForeground (int16, const rgb_color);
bool SetForeground (int16 w, uchar r, uchar g, uchar b, uchar a = 255)
{ rgb_color color = {r, g, b, a}; return SetForeground (w, color); }
bool SetForeground (int16 w, uchar r, uchar g, uchar b, uchar a = 255) {
rgb_color color = {r, g, b, a};
return SetForeground (w, color);
}
bool SetBackground (int16, const rgb_color);
bool SetBackground (int16 w, uchar r, uchar g, uchar b, uchar a = 255)
{ rgb_color color = {r, g, b, a}; return SetBackground (w, color); }
bool SetBackground (int16 w, uchar r, uchar g, uchar b, uchar a = 255) {
rgb_color color = {r, g, b, a};
return SetBackground (w, color);
}
//bool SetFont (int16, const BFont &);
bool SetTextRender(int16, TextRender *);
bool SetTextRender(int16, TextRender*);
void SetSoftLineIndent(float indent);
void SetTextMargin(float margin);
float TextMargin() const { return fTextMargin; }
float SoftLineIndent() const { return fSoftLineIndent; }
float TextMargin() const {
return fTextMargin;
}
float SoftLineIndent() const {
return fSoftLineIndent;
}
void AddView (BView *);
void RemoveView (BView *);
void AddView (BView*);
void RemoveView (BView*);
};

View File

@ -24,7 +24,7 @@
#include "URLCrunch.h"
URLCrunch::URLCrunch (const char *data, int32 len)
URLCrunch::URLCrunch (const char* data, int32 len)
: buffer (""),
current_pos (0)
{
@ -36,14 +36,13 @@ URLCrunch::~URLCrunch (void)
}
int32
URLCrunch::Crunch (BString *url)
URLCrunch::Crunch (BString* url)
{
if (current_pos >= buffer.Length())
return B_ERROR;
const int32 tagNum = 7;
const char *tags[tagNum] =
{
const char* tags[tagNum] = {
"http://",
"https://",
"www.",
@ -65,8 +64,7 @@ URLCrunch::Crunch (BString *url)
for (i = 0; i < tagNum; ++i)
if (markers[i] != B_ERROR
&& markers[i] < marker)
{
&& markers[i] < marker) {
url_length = markers[i] + strlen(tags[i]);
url_length += strcspn (buffer.String() + url_length, " \t\n|\\<>\")(][}{;'*^");
@ -76,18 +74,15 @@ URLCrunch::Crunch (BString *url)
if (url_length - markers[i] > len
&& (isdigit (buffer[markers[i] + len])
|| isalpha (buffer[markers[i] + len])))
{
|| isalpha (buffer[markers[i] + len]))) {
marker = markers[i];
pos = url_length + 1;
url_length -= marker;
}
else
} else
pos = markers[i] + 1;
}
if (marker < buffer.Length())
{
if (marker < buffer.Length()) {
*url = "";
url->Append (buffer.String() + marker, url_length);

View File

@ -30,11 +30,11 @@ class URLCrunch
BString buffer;
int32 current_pos;
public:
public:
URLCrunch (const char *, int32);
URLCrunch (const char*, int32);
~URLCrunch (void);
int32 Crunch (BString *);
int32 Crunch (BString*);
};
#endif

View File

@ -33,7 +33,7 @@
const float doubleClickThresh = 6;
BString
GetWord (const char *cData, int32 wordNeeded)
GetWord (const char* cData, int32 wordNeeded)
{
/*
* Function purpose: Get word number {wordNeeded} from {cData}
@ -44,8 +44,7 @@ GetWord (const char *cData, int32 wordNeeded)
BString buffer ("-9z99");
int32 wordAt (1), place (0);
while (wordAt != wordNeeded && place != B_ERROR)
{
while (wordAt != wordNeeded && place != B_ERROR) {
if ((place = data.FindFirst ('\x20', place)) != B_ERROR)
if (++place < data.Length()
&& data[place] != '\x20')
@ -54,8 +53,7 @@ GetWord (const char *cData, int32 wordNeeded)
if (wordAt == wordNeeded
&& place != B_ERROR
&& place < data.Length())
{
&& place < data.Length()) {
int32 end (data.FindFirst ('\x20', place));
if (end == B_ERROR)
@ -68,7 +66,7 @@ GetWord (const char *cData, int32 wordNeeded)
}
BString
GetWordColon (const char *cData, int32 wordNeeded)
GetWordColon (const char* cData, int32 wordNeeded)
{
/*
* Function purpose: Get word number {wordNeeded} from {cData}
@ -79,8 +77,7 @@ GetWordColon (const char *cData, int32 wordNeeded)
BString buffer ("-9z99");
int32 wordAt (1), place (0);
while (wordAt != wordNeeded && place != B_ERROR)
{
while (wordAt != wordNeeded && place != B_ERROR) {
if ((place = data.FindFirst (':', place)) != B_ERROR)
if (++place < data.Length()
&& data[place] != ':')
@ -89,8 +86,7 @@ GetWordColon (const char *cData, int32 wordNeeded)
if (wordAt == wordNeeded
&& place != B_ERROR
&& place < data.Length())
{
&& place < data.Length()) {
int32 end (data.FindFirst (':', place));
if (end == B_ERROR)
@ -103,7 +99,7 @@ GetWordColon (const char *cData, int32 wordNeeded)
}
BString
RestOfString (const char *cData, int32 wordStart)
RestOfString (const char* cData, int32 wordStart)
{
/*
* Function purpose: Get word number {wordStart} from {cData}
@ -115,8 +111,7 @@ RestOfString (const char *cData, int32 wordStart)
int32 wordAt (1), place (0);
BString buffer ("-9z99");
while (wordAt != wordStart && place != B_ERROR)
{
while (wordAt != wordStart && place != B_ERROR) {
if ((place = data.FindFirst ('\x20', place)) != B_ERROR)
if (++place < data.Length()
&& data[place] != '\x20')
@ -132,7 +127,7 @@ RestOfString (const char *cData, int32 wordStart)
}
BString
GetNick (const char *cData)
GetNick (const char* cData)
{
/*
* Function purpose: Get nickname from {cData}
@ -150,7 +145,7 @@ GetNick (const char *cData)
}
BString
GetIdent (const char *cData)
GetIdent (const char* cData)
{
/*
* Function purpose: Get identname/username from {cData}
@ -163,8 +158,7 @@ GetIdent (const char *cData)
int32 place[2];
if ((place[0] = data.FindFirst ('!')) != B_ERROR
&& (place[1] = data.FindFirst ('@')) != B_ERROR)
{
&& (place[1] = data.FindFirst ('@')) != B_ERROR) {
++(place[0]);
data.CopyInto (theIdent, place[0], place[1] - place[0]);
}
@ -173,7 +167,7 @@ GetIdent (const char *cData)
}
BString
GetAddress (const char *cData)
GetAddress (const char* cData)
{
/*
* Function purpose: Get address/hostname from {cData}
@ -185,8 +179,7 @@ GetAddress (const char *cData)
BString address;
int32 place;
if ((place = data.FindFirst ('@')) != B_ERROR)
{
if ((place = data.FindFirst ('@')) != B_ERROR) {
int32 length (data.FindFirst ('\x20', place));
if (length == B_ERROR)
@ -207,11 +200,11 @@ TimeStamp()
*
*/
// if(!vision_app->GetBool ("timestamp"))
// return "";
// if(!vision_app->GetBool ("timestamp"))
// return "";
// const char *ts_format (vision_app->GetString ("timestamp_format"));
const char *ts_format = "[%H:%M]";
// const char *ts_format (vision_app->GetString ("timestamp_format"));
const char* ts_format = "[%H:%M]";
time_t myTime (time (0));
tm curTime;
@ -226,17 +219,15 @@ TimeStamp()
BString
ExpandKeyed (
const char *incoming,
const char *keys,
const char **expansions)
const char* incoming,
const char* keys,
const char** expansions)
{
BString buffer;
while (incoming && *incoming)
{
if (*incoming == '$')
{
const char *place;
while (incoming && *incoming) {
if (*incoming == '$') {
const char* place;
++incoming;
@ -244,8 +235,7 @@ ExpandKeyed (
buffer += expansions[place - keys];
else
buffer += *incoming;
}
else
} else
buffer += *incoming;
++incoming;
@ -257,7 +247,7 @@ ExpandKeyed (
}
BString
StringToURI (const char *string)
StringToURI (const char* string)
{
/*
* Function purpose: Converts {string} to a URI safe format
@ -297,23 +287,23 @@ DurationString (int64 value)
BString duration;
bigtime_t micro = value;
bigtime_t milli = micro/1000;
bigtime_t sec = milli/1000;
bigtime_t min = sec/60;
bigtime_t hours = min/60;
bigtime_t days = hours/24;
bigtime_t milli = micro / 1000;
bigtime_t sec = milli / 1000;
bigtime_t min = sec / 60;
bigtime_t hours = min / 60;
bigtime_t days = hours / 24;
char message[512] = "";
if (days)
sprintf(message, "%Ld day%s ",days,days!=1?"s":"");
sprintf(message, "%Ld day%s ", days, days != 1 ? "s" : "");
if (hours%24)
sprintf(message, "%s%Ld hr%s ",message, hours%24,(hours%24)!=1?"s":"");
if (hours % 24)
sprintf(message, "%s%Ld hr%s ", message, hours % 24, (hours % 24) != 1 ? "s" : "");
if (min%60)
sprintf(message, "%s%Ld min%s ",message, min%60, (min%60)!=1?"s":"");
if (min % 60)
sprintf(message, "%s%Ld min%s ", message, min % 60, (min % 60) != 1 ? "s" : "");
sprintf(message, "%s%Ld.%Ld sec%s",message, sec%60, (milli%1000), (sec%60)!=1?"s":"");
sprintf(message, "%s%Ld.%Ld sec%s", message, sec % 60, (milli % 1000), (sec % 60) != 1 ? "s" : "");
duration += message;
@ -322,7 +312,7 @@ DurationString (int64 value)
const char *
RelToAbsPath (const char *append_)
RelToAbsPath (const char* append_)
{
app_info ai;
be_app->GetAppInfo (&ai);
@ -338,14 +328,13 @@ RelToAbsPath (const char *append_)
int32
Get440Len (const char *cData)
Get440Len (const char* cData)
{
BString data (cData);
if (data.Length() < 440)
return data.Length();
else
{
else {
int32 place (data.FindLast ('\x20', 440));
if (place == B_ERROR)
return 440;
@ -354,7 +343,7 @@ Get440Len (const char *cData)
}
uint16
CheckClickCount(BPoint point, BPoint &lastClick, bigtime_t sysTime, bigtime_t &lastClickTime, int16 &clickCount)
CheckClickCount(BPoint point, BPoint& lastClick, bigtime_t sysTime, bigtime_t& lastClickTime, int16& clickCount)
{
// check time and proximity
BPoint delta = point - lastClick;

View File

@ -26,45 +26,43 @@
#include <String.h>
template<class T> class AutoDestructor {
public:
AutoDestructor(T *t)
{
template<class T> class AutoDestructor
{
public:
AutoDestructor(T* t) {
fObject = t;
}
virtual ~AutoDestructor(void)
{
virtual ~AutoDestructor(void) {
delete fObject;
}
void SetTo(T *t)
{
void SetTo(T* t) {
delete fObject;
fObject = t;
}
private:
T *fObject;
private:
T* fObject;
};
class BMessage;
class BPoint;
BString GetWord (const char *, int32);
BString RestOfString (const char *, int32);
BString GetNick (const char *);
BString GetIdent (const char *);
BString GetAddress (const char *);
BString GetWord (const char*, int32);
BString RestOfString (const char*, int32);
BString GetNick (const char*);
BString GetIdent (const char*);
BString GetAddress (const char*);
BString TimeStamp (void);
BString ExpandKeyed (const char *, const char *, const char **);
BString ExpandKeyed (const char*, const char*, const char**);
BString DurationString (int64);
BString StringToURI (const char *);
const char *RelToAbsPath (const char *);
BString GetWordColon (const char *, int32);
int32 Get440Len (const char *);
uint16 CheckClickCount(BPoint, BPoint &, bigtime_t, bigtime_t &, int16 &);
BString StringToURI (const char*);
const char* RelToAbsPath (const char*);
BString GetWordColon (const char*, int32);
int32 Get440Len (const char*);
uint16 CheckClickCount(BPoint, BPoint&, bigtime_t, bigtime_t&, int16&);
#endif