* Removed src/kits/tracker/OpenHashTable.h. The shared version in
headers/private/shared is newer, though with small interface changes. * Removed the unnecessary Debug.h include in headers/private/shared/ObjectList.h. * Adjusted sources using these headers, mostly by adding missing includes. * Lots of automatic whitespace cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30123 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -65,7 +65,8 @@ All rights reserved.
|
|||||||
#include <List.h>
|
#include <List.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <Debug.h>
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
|
|
||||||
template<class T> class BObjectList;
|
template<class T> class BObjectList;
|
||||||
|
|
||||||
@@ -79,12 +80,12 @@ struct UnaryPredicate {
|
|||||||
|
|
||||||
private:
|
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>
|
template<class T>
|
||||||
int
|
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);
|
||||||
@@ -96,7 +97,7 @@ public:
|
|||||||
_PointerList_(const _PointerList_ &list);
|
_PointerList_(const _PointerList_ &list);
|
||||||
_PointerList_(int32 itemsPerBlock = 20, bool owning = false);
|
_PointerList_(int32 itemsPerBlock = 20, bool owning = false);
|
||||||
~_PointerList_();
|
~_PointerList_();
|
||||||
|
|
||||||
typedef void *(* GenericEachFunction)(void *, void *);
|
typedef void *(* GenericEachFunction)(void *, void *);
|
||||||
typedef int (* GenericCompareFunction)(const void *, const void *);
|
typedef int (* GenericCompareFunction)(const void *, const void *);
|
||||||
typedef int (* GenericCompareFunctionWithState)(const void *, const void *,
|
typedef int (* GenericCompareFunctionWithState)(const void *, const void *,
|
||||||
@@ -108,7 +109,7 @@ public:
|
|||||||
void SortItems(GenericCompareFunctionWithState, void *state);
|
void SortItems(GenericCompareFunctionWithState, void *state);
|
||||||
void HSortItems(GenericCompareFunction);
|
void HSortItems(GenericCompareFunction);
|
||||||
void HSortItems(GenericCompareFunctionWithState, void *state);
|
void HSortItems(GenericCompareFunctionWithState, void *state);
|
||||||
|
|
||||||
void *BinarySearch(const void *, GenericCompareFunction) const;
|
void *BinarySearch(const void *, GenericCompareFunction) const;
|
||||||
void *BinarySearch(const void *, GenericCompareFunctionWithState, void *state) const;
|
void *BinarySearch(const void *, GenericCompareFunctionWithState, void *state) const;
|
||||||
|
|
||||||
@@ -147,7 +148,7 @@ public:
|
|||||||
|
|
||||||
// adding and removing
|
// adding and removing
|
||||||
// ToDo:
|
// ToDo:
|
||||||
// change Add calls to return const item
|
// change Add calls to return const item
|
||||||
bool AddItem(T *);
|
bool AddItem(T *);
|
||||||
bool AddItem(T *, int32);
|
bool AddItem(T *, int32);
|
||||||
bool AddList(BObjectList *);
|
bool AddList(BObjectList *);
|
||||||
@@ -228,14 +229,14 @@ public:
|
|||||||
private:
|
private:
|
||||||
void SetItem(int32, T *);
|
void SetItem(int32, T *);
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class Item, class Result, class Param1>
|
template<class Item, class Result, class Param1>
|
||||||
Result
|
Result
|
||||||
WhileEachListItem(BObjectList<Item> *list, Result (Item::*func)(Param1), Param1 p1)
|
WhileEachListItem(BObjectList<Item> *list, Result (Item::*func)(Param1), Param1 p1)
|
||||||
{
|
{
|
||||||
Result result = 0;
|
Result result = 0;
|
||||||
int32 count = list->CountItems();
|
int32 count = list->CountItems();
|
||||||
|
|
||||||
for (int32 index = 0; index < count; index++)
|
for (int32 index = 0; index < count; index++)
|
||||||
if ((result = (list->ItemAt(index)->*func)(p1)) != 0)
|
if ((result = (list->ItemAt(index)->*func)(p1)) != 0)
|
||||||
break;
|
break;
|
||||||
@@ -244,12 +245,12 @@ WhileEachListItem(BObjectList<Item> *list, Result (Item::*func)(Param1), Param1
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class Item, class Result, class Param1>
|
template<class Item, class Result, class Param1>
|
||||||
Result
|
Result
|
||||||
WhileEachListItem(BObjectList<Item> *list, Result (*func)(Item *, Param1), Param1 p1)
|
WhileEachListItem(BObjectList<Item> *list, Result (*func)(Item *, Param1), Param1 p1)
|
||||||
{
|
{
|
||||||
Result result = 0;
|
Result result = 0;
|
||||||
int32 count = list->CountItems();
|
int32 count = list->CountItems();
|
||||||
|
|
||||||
for (int32 index = 0; index < count; index++)
|
for (int32 index = 0; index < count; index++)
|
||||||
if ((result = (*func)(list->ItemAt(index), p1)) != 0)
|
if ((result = (*func)(list->ItemAt(index), p1)) != 0)
|
||||||
break;
|
break;
|
||||||
@@ -258,13 +259,13 @@ WhileEachListItem(BObjectList<Item> *list, Result (*func)(Item *, Param1), Param
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class Item, class Result, class Param1, class Param2>
|
template<class Item, class Result, class Param1, class Param2>
|
||||||
Result
|
Result
|
||||||
WhileEachListItem(BObjectList<Item> *list, Result (Item::*func)(Param1, Param2),
|
WhileEachListItem(BObjectList<Item> *list, Result (Item::*func)(Param1, Param2),
|
||||||
Param1 p1, Param2 p2)
|
Param1 p1, Param2 p2)
|
||||||
{
|
{
|
||||||
Result result = 0;
|
Result result = 0;
|
||||||
int32 count = list->CountItems();
|
int32 count = list->CountItems();
|
||||||
|
|
||||||
for (int32 index = 0; index < count; index++)
|
for (int32 index = 0; index < count; index++)
|
||||||
if ((result = (list->ItemAt(index)->*func)(p1, p2)) != 0)
|
if ((result = (list->ItemAt(index)->*func)(p1, p2)) != 0)
|
||||||
break;
|
break;
|
||||||
@@ -273,13 +274,13 @@ WhileEachListItem(BObjectList<Item> *list, Result (Item::*func)(Param1, Param2),
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class Item, class Result, class Param1, class Param2>
|
template<class Item, class Result, class Param1, class Param2>
|
||||||
Result
|
Result
|
||||||
WhileEachListItem(BObjectList<Item> *list, Result (*func)(Item *, Param1, Param2),
|
WhileEachListItem(BObjectList<Item> *list, Result (*func)(Item *, Param1, Param2),
|
||||||
Param1 p1, Param2 p2)
|
Param1 p1, Param2 p2)
|
||||||
{
|
{
|
||||||
Result result = 0;
|
Result result = 0;
|
||||||
int32 count = list->CountItems();
|
int32 count = list->CountItems();
|
||||||
|
|
||||||
for (int32 index = 0; index < count; index++)
|
for (int32 index = 0; index < count; index++)
|
||||||
if ((result = (*func)(list->ItemAt(index), p1, p2)) != 0)
|
if ((result = (*func)(list->ItemAt(index), p1, p2)) != 0)
|
||||||
break;
|
break;
|
||||||
@@ -288,13 +289,13 @@ WhileEachListItem(BObjectList<Item> *list, Result (*func)(Item *, Param1, Param2
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class Item, class Result, class Param1, class Param2, class Param3, class Param4>
|
template<class Item, class Result, class Param1, class Param2, class Param3, class Param4>
|
||||||
Result
|
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)
|
Param3, Param4), Param1 p1, Param2 p2, Param3 p3, Param4 p4)
|
||||||
{
|
{
|
||||||
Result result = 0;
|
Result result = 0;
|
||||||
int32 count = list->CountItems();
|
int32 count = list->CountItems();
|
||||||
|
|
||||||
for (int32 index = 0; index < count; index++)
|
for (int32 index = 0; index < count; index++)
|
||||||
if ((result = (*func)(list->ItemAt(index), p1, p2, p3, p4)) != 0)
|
if ((result = (*func)(list->ItemAt(index), p1, p2, p3, p4)) != 0)
|
||||||
break;
|
break;
|
||||||
@@ -303,7 +304,7 @@ WhileEachListItem(BObjectList<Item> *list, Result (*func)(Item *, Param1, Param2
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class Item, class Result>
|
template<class Item, class Result>
|
||||||
void
|
void
|
||||||
EachListItemIgnoreResult(BObjectList<Item> *list, Result (Item::*func)())
|
EachListItemIgnoreResult(BObjectList<Item> *list, Result (Item::*func)())
|
||||||
{
|
{
|
||||||
int32 count = list->CountItems();
|
int32 count = list->CountItems();
|
||||||
@@ -312,7 +313,7 @@ EachListItemIgnoreResult(BObjectList<Item> *list, Result (Item::*func)())
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class Item, class Param1>
|
template<class Item, class Param1>
|
||||||
void
|
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();
|
int32 count = list->CountItems();
|
||||||
@@ -321,7 +322,7 @@ EachListItem(BObjectList<Item> *list, void (*func)(Item *, Param1), Param1 p1)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class Item, class Param1, class Param2>
|
template<class Item, class Param1, class Param2>
|
||||||
void
|
void
|
||||||
EachListItem(BObjectList<Item> *list, void (Item::*func)(Param1, Param2),
|
EachListItem(BObjectList<Item> *list, void (Item::*func)(Param1, Param2),
|
||||||
Param1 p1, Param2 p2)
|
Param1 p1, Param2 p2)
|
||||||
{
|
{
|
||||||
@@ -331,7 +332,7 @@ EachListItem(BObjectList<Item> *list, void (Item::*func)(Param1, Param2),
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class Item, class Param1, class Param2>
|
template<class Item, class Param1, class Param2>
|
||||||
void
|
void
|
||||||
EachListItem(BObjectList<Item> *list, void (*func)(Item *,Param1, Param2),
|
EachListItem(BObjectList<Item> *list, void (*func)(Item *,Param1, Param2),
|
||||||
Param1 p1, Param2 p2)
|
Param1 p1, Param2 p2)
|
||||||
{
|
{
|
||||||
@@ -341,7 +342,7 @@ EachListItem(BObjectList<Item> *list, void (*func)(Item *,Param1, Param2),
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class Item, class Param1, class Param2, class Param3>
|
template<class Item, class Param1, class Param2, class Param3>
|
||||||
void
|
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)
|
Param3), Param1 p1, Param2 p2, Param3 p3)
|
||||||
{
|
{
|
||||||
@@ -352,7 +353,7 @@ EachListItem(BObjectList<Item> *list, void (*func)(Item *,Param1, Param2,
|
|||||||
|
|
||||||
|
|
||||||
template<class Item, class Param1, class Param2, class Param3, class Param4>
|
template<class Item, class Param1, class Param2, class Param3, class Param4>
|
||||||
void
|
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)
|
Param3, Param4), Param1 p1, Param2 p2, Param3 p3, Param4 p4)
|
||||||
{
|
{
|
||||||
@@ -369,13 +370,13 @@ _PointerList_::Owning() const
|
|||||||
return owning;
|
return owning;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
BObjectList<T>::BObjectList(int32 itemsPerBlock, bool owning)
|
BObjectList<T>::BObjectList(int32 itemsPerBlock, bool owning)
|
||||||
: _PointerList_(itemsPerBlock, owning)
|
: _PointerList_(itemsPerBlock, owning)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
BObjectList<T>::BObjectList(const BObjectList<T> &list)
|
BObjectList<T>::BObjectList(const BObjectList<T> &list)
|
||||||
: _PointerList_(list)
|
: _PointerList_(list)
|
||||||
{
|
{
|
||||||
@@ -392,7 +393,7 @@ BObjectList<T>::BObjectList(const BObjectList<T> &list)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
BObjectList<T>::~BObjectList()
|
BObjectList<T>::~BObjectList()
|
||||||
{
|
{
|
||||||
if (Owning())
|
if (Owning())
|
||||||
@@ -400,7 +401,7 @@ BObjectList<T>::~BObjectList()
|
|||||||
MakeEmpty();
|
MakeEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
BObjectList<T> &
|
BObjectList<T> &
|
||||||
BObjectList<T>::operator=(const BObjectList<T> &list)
|
BObjectList<T>::operator=(const BObjectList<T> &list)
|
||||||
{
|
{
|
||||||
@@ -419,56 +420,56 @@ BObjectList<T>::operator=(const BObjectList<T> &list)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
bool
|
bool
|
||||||
BObjectList<T>::AddItem(T *item)
|
BObjectList<T>::AddItem(T *item)
|
||||||
{
|
{
|
||||||
// need to cast to void * to make T work for const pointers
|
// 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>
|
template<class T>
|
||||||
bool
|
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>
|
template<class T>
|
||||||
bool
|
bool
|
||||||
BObjectList<T>::AddList(BObjectList<T> *newItems)
|
BObjectList<T>::AddList(BObjectList<T> *newItems)
|
||||||
{
|
{
|
||||||
return _PointerList_::AddList(newItems);
|
return _PointerList_::AddList(newItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
bool
|
bool
|
||||||
BObjectList<T>::AddList(BObjectList<T> *newItems, int32 atIndex)
|
BObjectList<T>::AddList(BObjectList<T> *newItems, int32 atIndex)
|
||||||
{
|
{
|
||||||
return _PointerList_::AddList(newItems, atIndex);
|
return _PointerList_::AddList(newItems, atIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
bool
|
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)
|
if (result && Owning() && deleteIfOwning)
|
||||||
delete item;
|
delete item;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
T *
|
T *
|
||||||
BObjectList<T>::RemoveItemAt(int32 index)
|
BObjectList<T>::RemoveItemAt(int32 index)
|
||||||
{
|
{
|
||||||
return (T *)_PointerList_::RemoveItem(index);
|
return (T *)_PointerList_::RemoveItem(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline T *
|
inline T *
|
||||||
BObjectList<T>::ItemAt(int32 index) const
|
BObjectList<T>::ItemAt(int32 index) const
|
||||||
{
|
{
|
||||||
@@ -476,7 +477,7 @@ BObjectList<T>::ItemAt(int32 index) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
bool
|
bool
|
||||||
BObjectList<T>::ReplaceItem(int32 index, T *item)
|
BObjectList<T>::ReplaceItem(int32 index, T *item)
|
||||||
{
|
{
|
||||||
if (owning)
|
if (owning)
|
||||||
@@ -494,56 +495,56 @@ BObjectList<T>::SwapWithItem(int32 index, T *newItem)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void
|
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>
|
template<class T>
|
||||||
int32
|
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>
|
template<class T>
|
||||||
T *
|
T *
|
||||||
BObjectList<T>::FirstItem() const
|
BObjectList<T>::FirstItem() const
|
||||||
{
|
{
|
||||||
return (T *)_PointerList_::FirstItem();
|
return (T *)_PointerList_::FirstItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
T *
|
T *
|
||||||
BObjectList<T>::LastItem() const
|
BObjectList<T>::LastItem() const
|
||||||
{
|
{
|
||||||
return (T *)_PointerList_::LastItem();
|
return (T *)_PointerList_::LastItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
bool
|
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>
|
template<class T>
|
||||||
bool
|
bool
|
||||||
BObjectList<T>::IsEmpty() const
|
BObjectList<T>::IsEmpty() const
|
||||||
{
|
{
|
||||||
return _PointerList_::IsEmpty();
|
return _PointerList_::IsEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
int32
|
int32
|
||||||
BObjectList<T>::CountItems() const
|
BObjectList<T>::CountItems() const
|
||||||
{
|
{
|
||||||
return _PointerList_::CountItems();
|
return _PointerList_::CountItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void
|
void
|
||||||
BObjectList<T>::MakeEmpty()
|
BObjectList<T>::MakeEmpty()
|
||||||
{
|
{
|
||||||
if (owning) {
|
if (owning) {
|
||||||
@@ -554,21 +555,21 @@ BObjectList<T>::MakeEmpty()
|
|||||||
_PointerList_::MakeEmpty();
|
_PointerList_::MakeEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
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>
|
template<class T>
|
||||||
const 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(
|
const_cast<BObjectList<T> *>(this)->_PointerList_::EachElement(
|
||||||
(GenericEachFunction)func, params);
|
(GenericEachFunction)func, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
@@ -594,32 +595,32 @@ BObjectList<T>::FindIf(const UnaryPredicate<T> &predicate)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void
|
void
|
||||||
BObjectList<T>::SortItems(CompareFunction function)
|
BObjectList<T>::SortItems(CompareFunction function)
|
||||||
{
|
{
|
||||||
_PointerList_::SortItems((GenericCompareFunction)function);
|
_PointerList_::SortItems((GenericCompareFunction)function);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void
|
void
|
||||||
BObjectList<T>::SortItems(CompareFunctionWithState function, void *state)
|
BObjectList<T>::SortItems(CompareFunctionWithState function, void *state)
|
||||||
{
|
{
|
||||||
_PointerList_::SortItems((GenericCompareFunctionWithState)function, state);
|
_PointerList_::SortItems((GenericCompareFunctionWithState)function, state);
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
void
|
|
||||||
BObjectList<T>::HSortItems(CompareFunction function)
|
|
||||||
{
|
|
||||||
_PointerList_::HSortItems((GenericCompareFunction)function);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void
|
void
|
||||||
|
BObjectList<T>::HSortItems(CompareFunction function)
|
||||||
|
{
|
||||||
|
_PointerList_::HSortItems((GenericCompareFunction)function);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void
|
||||||
BObjectList<T>::HSortItems(CompareFunctionWithState function, void *state)
|
BObjectList<T>::HSortItems(CompareFunctionWithState function, void *state)
|
||||||
{
|
{
|
||||||
_PointerList_::HSortItems((GenericCompareFunctionWithState)function, state);
|
_PointerList_::HSortItems((GenericCompareFunctionWithState)function, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
@@ -667,7 +668,7 @@ BObjectList<T>::BinaryInsert(T *item, CompareFunctionWithState func, void *state
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
bool
|
bool
|
||||||
BObjectList<T>::BinaryInsertUnique(T *item, CompareFunction func)
|
BObjectList<T>::BinaryInsertUnique(T *item, CompareFunction func)
|
||||||
{
|
{
|
||||||
int32 index = _PointerList_::BinarySearchIndex(item,
|
int32 index = _PointerList_::BinarySearchIndex(item,
|
||||||
@@ -679,7 +680,7 @@ BObjectList<T>::BinaryInsertUnique(T *item, CompareFunction func)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
bool
|
bool
|
||||||
BObjectList<T>::BinaryInsertUnique(T *item, CompareFunctionWithState func, void *state)
|
BObjectList<T>::BinaryInsertUnique(T *item, CompareFunctionWithState func, void *state)
|
||||||
{
|
{
|
||||||
int32 index = _PointerList_::BinarySearchIndex(item,
|
int32 index = _PointerList_::BinarySearchIndex(item,
|
||||||
@@ -702,7 +703,7 @@ BObjectList<T>::BinaryInsertCopy(const T ©This, CompareFunction func)
|
|||||||
index++;
|
index++;
|
||||||
else
|
else
|
||||||
index = -index - 1;
|
index = -index - 1;
|
||||||
|
|
||||||
T *newItem = new T(copyThis);
|
T *newItem = new T(copyThis);
|
||||||
AddItem(newItem, index);
|
AddItem(newItem, index);
|
||||||
return newItem;
|
return newItem;
|
||||||
@@ -733,7 +734,7 @@ BObjectList<T>::BinaryInsertCopyUnique(const T ©This, CompareFunction func)
|
|||||||
(GenericCompareFunction)func);
|
(GenericCompareFunction)func);
|
||||||
if (index >= 0)
|
if (index >= 0)
|
||||||
return ItemAt(index);
|
return ItemAt(index);
|
||||||
|
|
||||||
index = -index - 1;
|
index = -index - 1;
|
||||||
T *newItem = new T(copyThis);
|
T *newItem = new T(copyThis);
|
||||||
AddItem(newItem, index);
|
AddItem(newItem, index);
|
||||||
@@ -749,7 +750,7 @@ BObjectList<T>::BinaryInsertCopyUnique(const T ©This, CompareFunctionWithSta
|
|||||||
(GenericCompareFunctionWithState)func, state);
|
(GenericCompareFunctionWithState)func, state);
|
||||||
if (index >= 0)
|
if (index >= 0)
|
||||||
return ItemAt(index);
|
return ItemAt(index);
|
||||||
|
|
||||||
index = -index - 1;
|
index = -index - 1;
|
||||||
T *newItem = new T(copyThis);
|
T *newItem = new T(copyThis);
|
||||||
AddItem(newItem, index);
|
AddItem(newItem, index);
|
||||||
@@ -757,19 +758,19 @@ BObjectList<T>::BinaryInsertCopyUnique(const T ©This, CompareFunctionWithSta
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
int32
|
int32
|
||||||
BObjectList<T>::FindBinaryInsertionIndex(const UnaryPredicate<T> &pred, bool *alreadyInList)
|
BObjectList<T>::FindBinaryInsertionIndex(const UnaryPredicate<T> &pred, bool *alreadyInList)
|
||||||
const
|
const
|
||||||
{
|
{
|
||||||
int32 index = _PointerList_::BinarySearchIndexByPredicate(&pred,
|
int32 index = _PointerList_::BinarySearchIndexByPredicate(&pred,
|
||||||
(UnaryPredicateGlue)&UnaryPredicate<T>::_unary_predicate_glue);
|
(UnaryPredicateGlue)&UnaryPredicate<T>::_unary_predicate_glue);
|
||||||
|
|
||||||
if (alreadyInList)
|
if (alreadyInList)
|
||||||
*alreadyInList = index >= 0;
|
*alreadyInList = index >= 0;
|
||||||
|
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
index = -index - 1;
|
index = -index - 1;
|
||||||
|
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
#include "ExtendedPartitionAddOn.h"
|
#include "ExtendedPartitionAddOn.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
#include <DiskDeviceTypes.h>
|
#include <DiskDeviceTypes.h>
|
||||||
@@ -17,7 +19,7 @@
|
|||||||
using std::nothrow;
|
using std::nothrow;
|
||||||
|
|
||||||
|
|
||||||
static const uint32 kDiskSystemFlags =
|
static const uint32 kDiskSystemFlags =
|
||||||
0
|
0
|
||||||
// | B_DISK_SYSTEM_SUPPORTS_CHECKING
|
// | B_DISK_SYSTEM_SUPPORTS_CHECKING
|
||||||
// | B_DISK_SYSTEM_SUPPORTS_REPAIRING
|
// | B_DISK_SYSTEM_SUPPORTS_REPAIRING
|
||||||
|
|||||||
@@ -8,6 +8,9 @@
|
|||||||
#include "ProbeView.h"
|
#include "ProbeView.h"
|
||||||
#include "TypeEditors.h"
|
#include "TypeEditors.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <MenuBar.h>
|
#include <MenuBar.h>
|
||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
#include <TabView.h>
|
#include <TabView.h>
|
||||||
@@ -62,7 +65,7 @@ EditorTabView::EditorTabView(BRect frame, const char *name, button_width width,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
EditorTabView::FrameResized(float width, float height)
|
EditorTabView::FrameResized(float width, float height)
|
||||||
{
|
{
|
||||||
BRect rect = Bounds();
|
BRect rect = Bounds();
|
||||||
@@ -84,7 +87,7 @@ EditorTabView::FrameResized(float width, float height)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
EditorTabView::Select(int32 tab)
|
EditorTabView::Select(int32 tab)
|
||||||
{
|
{
|
||||||
if (tab != fRawTab && fRawEditorView != NULL && !fRawEditorView->IsHidden(fRawEditorView))
|
if (tab != fRawTab && fRawEditorView != NULL && !fRawEditorView->IsHidden(fRawEditorView))
|
||||||
@@ -131,7 +134,7 @@ EditorTabView::AddRawEditorTab(BView *view)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
EditorTabView::SetTypeEditorTab(BView *view)
|
EditorTabView::SetTypeEditorTab(BView *view)
|
||||||
{
|
{
|
||||||
if (fTypeEditorView == view)
|
if (fTypeEditorView == view)
|
||||||
@@ -257,7 +260,7 @@ AttributeWindow::~AttributeWindow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AttributeWindow::MessageReceived(BMessage *message)
|
AttributeWindow::MessageReceived(BMessage *message)
|
||||||
{
|
{
|
||||||
switch (message->what) {
|
switch (message->what) {
|
||||||
@@ -289,7 +292,7 @@ AttributeWindow::MessageReceived(BMessage *message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
AttributeWindow::QuitRequested()
|
AttributeWindow::QuitRequested()
|
||||||
{
|
{
|
||||||
if (fTypeEditorView != NULL)
|
if (fTypeEditorView != NULL)
|
||||||
|
|||||||
@@ -8,11 +8,13 @@
|
|||||||
|
|
||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
#include <NodeMonitor.h>
|
#include <NodeMonitor.h>
|
||||||
|
#include <Debug.h>
|
||||||
#include <Directory.h>
|
#include <Directory.h>
|
||||||
#include <Drivers.h>
|
#include <Drivers.h>
|
||||||
#include <fs_attr.h>
|
#include <fs_attr.h>
|
||||||
#include <fs_info.h>
|
#include <fs_info.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
@@ -178,7 +180,7 @@ DataChange::~DataChange()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
DataChange::Merge(DataChange *change)
|
DataChange::Merge(DataChange *change)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -196,7 +198,7 @@ ReplaceChange::ReplaceChange(off_t offset, const uint8 *data, size_t size)
|
|||||||
fOldData = (uint8 *)malloc(size);
|
fOldData = (uint8 *)malloc(size);
|
||||||
if (fNewData != NULL && fOldData != NULL) {
|
if (fNewData != NULL && fOldData != NULL) {
|
||||||
memcpy(fNewData, data, size);
|
memcpy(fNewData, data, size);
|
||||||
fSize = size;
|
fSize = size;
|
||||||
} else
|
} else
|
||||||
fSize = 0;
|
fSize = 0;
|
||||||
}
|
}
|
||||||
@@ -215,7 +217,7 @@ ReplaceChange::~ReplaceChange()
|
|||||||
* method.
|
* method.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
ReplaceChange::Normalize(off_t bufferOffset, size_t bufferSize, off_t &offset,
|
ReplaceChange::Normalize(off_t bufferOffset, size_t bufferSize, off_t &offset,
|
||||||
size_t &dataOffset, size_t &size)
|
size_t &dataOffset, size_t &size)
|
||||||
{
|
{
|
||||||
@@ -230,7 +232,7 @@ ReplaceChange::Normalize(off_t bufferOffset, size_t bufferSize, off_t &offset,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ReplaceChange::Apply(off_t bufferOffset, uint8 *buffer, size_t bufferSize)
|
ReplaceChange::Apply(off_t bufferOffset, uint8 *buffer, size_t bufferSize)
|
||||||
{
|
{
|
||||||
// is it in our range?
|
// is it in our range?
|
||||||
@@ -257,7 +259,7 @@ ReplaceChange::Apply(off_t bufferOffset, uint8 *buffer, size_t bufferSize)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ReplaceChange::Revert(off_t bufferOffset, uint8 *buffer, size_t bufferSize)
|
ReplaceChange::Revert(off_t bufferOffset, uint8 *buffer, size_t bufferSize)
|
||||||
{
|
{
|
||||||
// is it in our range?
|
// is it in our range?
|
||||||
@@ -283,7 +285,7 @@ ReplaceChange::Revert(off_t bufferOffset, uint8 *buffer, size_t bufferSize)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ReplaceChange::Merge(DataChange *_change)
|
ReplaceChange::Merge(DataChange *_change)
|
||||||
{
|
{
|
||||||
ReplaceChange *change = dynamic_cast<ReplaceChange *>(_change);
|
ReplaceChange *change = dynamic_cast<ReplaceChange *>(_change);
|
||||||
@@ -323,7 +325,7 @@ ReplaceChange::Merge(DataChange *_change)
|
|||||||
// if this fails, we can't do anything about it
|
// if this fails, we can't do anything about it
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fOffset < change->fOffset) {
|
if (fOffset < change->fOffset) {
|
||||||
memcpy(newData + fSize, change->fNewData, change->fSize);
|
memcpy(newData + fSize, change->fNewData, change->fSize);
|
||||||
memcpy(oldData + fSize, change->fOldData, change->fSize);
|
memcpy(oldData + fSize, change->fOldData, change->fSize);
|
||||||
@@ -350,7 +352,7 @@ ReplaceChange::Merge(DataChange *_change)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ReplaceChange::GetRange(off_t /*fileSize*/, off_t &_offset, off_t &_size)
|
ReplaceChange::GetRange(off_t /*fileSize*/, off_t &_offset, off_t &_size)
|
||||||
{
|
{
|
||||||
_offset = fOffset;
|
_offset = fOffset;
|
||||||
@@ -392,7 +394,7 @@ DataEditor::~DataEditor()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
DataEditor::SetTo(const char *path, const char *attribute)
|
DataEditor::SetTo(const char *path, const char *attribute)
|
||||||
{
|
{
|
||||||
BEntry entry(path);
|
BEntry entry(path);
|
||||||
@@ -400,7 +402,7 @@ DataEditor::SetTo(const char *path, const char *attribute)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
DataEditor::SetTo(entry_ref &ref, const char *attribute)
|
DataEditor::SetTo(entry_ref &ref, const char *attribute)
|
||||||
{
|
{
|
||||||
BEntry entry(&ref);
|
BEntry entry(&ref);
|
||||||
@@ -408,7 +410,7 @@ DataEditor::SetTo(entry_ref &ref, const char *attribute)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
DataEditor::SetTo(BEntry &entry, const char *attribute)
|
DataEditor::SetTo(BEntry &entry, const char *attribute)
|
||||||
{
|
{
|
||||||
fSize = 0;
|
fSize = 0;
|
||||||
@@ -516,7 +518,7 @@ DataEditor::SetTo(BEntry &entry, const char *attribute)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
DataEditor::InitCheck()
|
DataEditor::InitCheck()
|
||||||
{
|
{
|
||||||
return fFile.InitCheck();
|
return fFile.InitCheck();
|
||||||
@@ -747,7 +749,7 @@ DataEditor::RemoveRedos()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
DataEditor::Undo()
|
DataEditor::Undo()
|
||||||
{
|
{
|
||||||
BAutolock locker(this);
|
BAutolock locker(this);
|
||||||
@@ -776,7 +778,7 @@ DataEditor::Undo()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
DataEditor::Redo()
|
DataEditor::Redo()
|
||||||
{
|
{
|
||||||
BAutolock locker(this);
|
BAutolock locker(this);
|
||||||
@@ -863,7 +865,7 @@ DataEditor::SetViewOffset(off_t offset)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
DataEditor::SetViewSize(size_t size, bool sendNotices)
|
DataEditor::SetViewSize(size_t size, bool sendNotices)
|
||||||
{
|
{
|
||||||
BAutolock locker(this);
|
BAutolock locker(this);
|
||||||
@@ -979,7 +981,7 @@ DataEditor::UpdateIfNeeded(bool *_updated)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
DataEditor::ForceUpdate()
|
DataEditor::ForceUpdate()
|
||||||
{
|
{
|
||||||
BAutolock locker(this);
|
BAutolock locker(this);
|
||||||
@@ -1045,7 +1047,7 @@ DataEditor::GetViewBuffer(const uint8 **_buffer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
off_t
|
off_t
|
||||||
DataEditor::Find(off_t startPosition, const uint8 *data, size_t dataSize,
|
DataEditor::Find(off_t startPosition, const uint8 *data, size_t dataSize,
|
||||||
bool caseInsensitive, bool cyclic, BMessenger progressMonitor,
|
bool caseInsensitive, bool cyclic, BMessenger progressMonitor,
|
||||||
volatile bool *stop)
|
volatile bool *stop)
|
||||||
@@ -1191,7 +1193,7 @@ DataEditor::SendNotices(DataChange *change)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DataEditor::SendNotices(uint32 what, BMessage *message)
|
DataEditor::SendNotices(uint32 what, BMessage *message)
|
||||||
{
|
{
|
||||||
if (fObservers.CountItems() == 0)
|
if (fObservers.CountItems() == 0)
|
||||||
@@ -1213,7 +1215,7 @@ DataEditor::SendNotices(uint32 what, BMessage *message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
DataEditor::StartWatching(BMessenger target)
|
DataEditor::StartWatching(BMessenger target)
|
||||||
{
|
{
|
||||||
BAutolock locker(this);
|
BAutolock locker(this);
|
||||||
@@ -1236,7 +1238,7 @@ DataEditor::StartWatching(BHandler *handler, BLooper *looper)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DataEditor::StopWatching(BMessenger target)
|
DataEditor::StopWatching(BMessenger target)
|
||||||
{
|
{
|
||||||
BAutolock locker(this);
|
BAutolock locker(this);
|
||||||
@@ -1254,7 +1256,7 @@ DataEditor::StopWatching(BMessenger target)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DataEditor::StopWatching(BHandler *handler, BLooper *looper)
|
DataEditor::StopWatching(BHandler *handler, BLooper *looper)
|
||||||
{
|
{
|
||||||
StopWatching(BMessenger(handler, looper));
|
StopWatching(BMessenger(handler, looper));
|
||||||
|
|||||||
@@ -7,6 +7,9 @@
|
|||||||
#include "DataView.h"
|
#include "DataView.h"
|
||||||
#include "DataEditor.h"
|
#include "DataEditor.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
#include <ScrollBar.h>
|
#include <ScrollBar.h>
|
||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
|
|||||||
@@ -11,6 +11,9 @@
|
|||||||
# include <IconUtils.h>
|
# include <IconUtils.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
@@ -27,8 +30,6 @@
|
|||||||
#include <TranslationUtils.h>
|
#include <TranslationUtils.h>
|
||||||
#include <TranslatorFormats.h>
|
#include <TranslatorFormats.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
|
|
||||||
static const uint32 kMsgValueChanged = 'vlch';
|
static const uint32 kMsgValueChanged = 'vlch';
|
||||||
static const uint32 kMsgScaleChanged = 'scch';
|
static const uint32 kMsgScaleChanged = 'scch';
|
||||||
@@ -254,7 +255,7 @@ StringEditor::AttachedToWindow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
StringEditor::DetachedFromWindow()
|
StringEditor::DetachedFromWindow()
|
||||||
{
|
{
|
||||||
fEditor.StopWatching(this);
|
fEditor.StopWatching(this);
|
||||||
@@ -305,7 +306,7 @@ MimeTypeEditor::_UpdateText()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MimeTypeEditor::CommitChanges()
|
MimeTypeEditor::CommitChanges()
|
||||||
{
|
{
|
||||||
if (fPreviousText != fTextControl->Text()) {
|
if (fPreviousText != fTextControl->Text()) {
|
||||||
@@ -333,7 +334,7 @@ MimeTypeEditor::AttachedToWindow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MimeTypeEditor::DetachedFromWindow()
|
MimeTypeEditor::DetachedFromWindow()
|
||||||
{
|
{
|
||||||
fEditor.StopWatching(this);
|
fEditor.StopWatching(this);
|
||||||
@@ -379,7 +380,7 @@ NumberEditor::NumberEditor(BRect rect, DataEditor &editor)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
NumberEditor::_UpdateText()
|
NumberEditor::_UpdateText()
|
||||||
{
|
{
|
||||||
if (fEditor.Lock()) {
|
if (fEditor.Lock()) {
|
||||||
@@ -625,7 +626,7 @@ NumberEditor::_TypeLabel()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
NumberEditor::_Size()
|
NumberEditor::_Size()
|
||||||
{
|
{
|
||||||
switch (fEditor.Type()) {
|
switch (fEditor.Type()) {
|
||||||
@@ -711,7 +712,7 @@ NumberEditor::AttachedToWindow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
NumberEditor::DetachedFromWindow()
|
NumberEditor::DetachedFromWindow()
|
||||||
{
|
{
|
||||||
fEditor.StopWatching(this);
|
fEditor.StopWatching(this);
|
||||||
@@ -774,7 +775,7 @@ BooleanEditor::TypeMatches()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BooleanEditor::_UpdateMenuField()
|
BooleanEditor::_UpdateMenuField()
|
||||||
{
|
{
|
||||||
if (fEditor.FileSize() != 1)
|
if (fEditor.FileSize() != 1)
|
||||||
@@ -790,14 +791,14 @@ BooleanEditor::_UpdateMenuField()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BooleanEditor::CommitChanges()
|
BooleanEditor::CommitChanges()
|
||||||
{
|
{
|
||||||
// we're commiting the changes as they happen
|
// we're commiting the changes as they happen
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BooleanEditor::AttachedToWindow()
|
BooleanEditor::AttachedToWindow()
|
||||||
{
|
{
|
||||||
fTrueMenuItem->SetTarget(this);
|
fTrueMenuItem->SetTarget(this);
|
||||||
@@ -807,14 +808,14 @@ BooleanEditor::AttachedToWindow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BooleanEditor::DetachedFromWindow()
|
BooleanEditor::DetachedFromWindow()
|
||||||
{
|
{
|
||||||
fEditor.StopWatching(this);
|
fEditor.StopWatching(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BooleanEditor::MessageReceived(BMessage *message)
|
BooleanEditor::MessageReceived(BMessage *message)
|
||||||
{
|
{
|
||||||
switch (message->what) {
|
switch (message->what) {
|
||||||
@@ -842,7 +843,7 @@ ImageView::ImageView(BRect rect, DataEditor &editor)
|
|||||||
fBitmap(NULL),
|
fBitmap(NULL),
|
||||||
fScaleSlider(NULL)
|
fScaleSlider(NULL)
|
||||||
{
|
{
|
||||||
if (editor.Type() == B_MINI_ICON_TYPE || editor.Type() == B_LARGE_ICON_TYPE
|
if (editor.Type() == B_MINI_ICON_TYPE || editor.Type() == B_LARGE_ICON_TYPE
|
||||||
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
||||||
|| editor.Type() == B_VECTOR_ICON_TYPE
|
|| editor.Type() == B_VECTOR_ICON_TYPE
|
||||||
#endif
|
#endif
|
||||||
@@ -876,7 +877,7 @@ ImageView::~ImageView()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ImageView::AttachedToWindow()
|
ImageView::AttachedToWindow()
|
||||||
{
|
{
|
||||||
if (Parent() != NULL)
|
if (Parent() != NULL)
|
||||||
@@ -892,7 +893,7 @@ ImageView::AttachedToWindow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ImageView::DetachedFromWindow()
|
ImageView::DetachedFromWindow()
|
||||||
{
|
{
|
||||||
fEditor.StopWatching(this);
|
fEditor.StopWatching(this);
|
||||||
@@ -1034,7 +1035,7 @@ ImageView::_UpdateImage()
|
|||||||
case B_MESSAGE_TYPE:
|
case B_MESSAGE_TYPE:
|
||||||
type = "Flattened Bitmap";
|
type = "Flattened Bitmap";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
const char *colorSpace;
|
const char *colorSpace;
|
||||||
@@ -1283,7 +1284,7 @@ MessageView::AttachedToWindow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MessageView::DetachedFromWindow()
|
MessageView::DetachedFromWindow()
|
||||||
{
|
{
|
||||||
fEditor.StopWatching(this);
|
fEditor.StopWatching(this);
|
||||||
|
|||||||
@@ -14,6 +14,9 @@
|
|||||||
#include "PartitionList.h"
|
#include "PartitionList.h"
|
||||||
#include "Support.h"
|
#include "Support.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
#include "Support.h"
|
#include "Support.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <Partition.h>
|
#include <Partition.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <DiskDevice.h>
|
#include <DiskDevice.h>
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
#include "DiskDeviceJobQueue.h"
|
#include "DiskDeviceJobQueue.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
|
|
||||||
#include "DiskDeviceJob.h"
|
#include "DiskDeviceJob.h"
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <new>
|
#include <new>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include <Directory.h>
|
#include <Directory.h>
|
||||||
|
|||||||
@@ -32,9 +32,11 @@ names are registered trademarks or trademarks of their respective holders.
|
|||||||
All rights reserved.
|
All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Node.h>
|
|
||||||
#include "AttributeStream.h"
|
#include "AttributeStream.h"
|
||||||
|
|
||||||
|
#include <Debug.h>
|
||||||
|
#include <Node.h>
|
||||||
|
|
||||||
// ToDo:
|
// ToDo:
|
||||||
// lazy Rewind from Drive, only if data is available
|
// lazy Rewind from Drive, only if data is available
|
||||||
// BMessage node
|
// BMessage node
|
||||||
@@ -43,7 +45,7 @@ All rights reserved.
|
|||||||
AttributeInfo::AttributeInfo(const AttributeInfo &cloneThis)
|
AttributeInfo::AttributeInfo(const AttributeInfo &cloneThis)
|
||||||
: fName(cloneThis.fName),
|
: fName(cloneThis.fName),
|
||||||
fInfo(cloneThis.fInfo)
|
fInfo(cloneThis.fInfo)
|
||||||
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,34 +70,34 @@ AttributeInfo::Name() const
|
|||||||
return fName.String();
|
return fName.String();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32
|
uint32
|
||||||
AttributeInfo::Type() const
|
AttributeInfo::Type() const
|
||||||
{
|
{
|
||||||
return fInfo.type;
|
return fInfo.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
off_t
|
off_t
|
||||||
AttributeInfo::Size() const
|
AttributeInfo::Size() const
|
||||||
{
|
{
|
||||||
return fInfo.size;
|
return fInfo.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AttributeInfo::SetTo(const AttributeInfo &attr)
|
AttributeInfo::SetTo(const AttributeInfo &attr)
|
||||||
{
|
{
|
||||||
fName = attr.fName;
|
fName = attr.fName;
|
||||||
fInfo = attr.fInfo;
|
fInfo = attr.fInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AttributeInfo::SetTo(const char *name, attr_info info)
|
AttributeInfo::SetTo(const char *name, attr_info info)
|
||||||
{
|
{
|
||||||
fName = name;
|
fName = name;
|
||||||
fInfo = info;
|
fInfo = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AttributeInfo::SetTo(const char *name, uint32 type, off_t size)
|
AttributeInfo::SetTo(const char *name, uint32 type, off_t size)
|
||||||
{
|
{
|
||||||
fName = name;
|
fName = name;
|
||||||
@@ -121,26 +123,26 @@ AttributeStreamNode::operator<<(AttributeStreamNode &source)
|
|||||||
{
|
{
|
||||||
fReadFrom = &source;
|
fReadFrom = &source;
|
||||||
fReadFrom->fWriteTo = this;
|
fReadFrom->fWriteTo = this;
|
||||||
if (fReadFrom->CanFeed())
|
if (fReadFrom->CanFeed())
|
||||||
fReadFrom->Start();
|
fReadFrom->Start();
|
||||||
|
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AttributeStreamNode::Rewind()
|
AttributeStreamNode::Rewind()
|
||||||
{
|
{
|
||||||
if (fReadFrom)
|
if (fReadFrom)
|
||||||
fReadFrom->Rewind();
|
fReadFrom->Rewind();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AttributeStreamFileNode::MakeEmpty()
|
AttributeStreamFileNode::MakeEmpty()
|
||||||
{
|
{
|
||||||
TRESPASS();
|
TRESPASS();
|
||||||
}
|
}
|
||||||
|
|
||||||
off_t
|
off_t
|
||||||
AttributeStreamNode::Contains(const char *name, uint32 type)
|
AttributeStreamNode::Contains(const char *name, uint32 type)
|
||||||
{
|
{
|
||||||
if (!fReadFrom)
|
if (!fReadFrom)
|
||||||
@@ -150,27 +152,27 @@ AttributeStreamNode::Contains(const char *name, uint32 type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
off_t
|
off_t
|
||||||
AttributeStreamNode::Read(const char *name, const char *foreignName, uint32 type,
|
AttributeStreamNode::Read(const char *name, const char *foreignName, uint32 type,
|
||||||
off_t size, void *buffer, void (*swapFunc)(void *))
|
off_t size, void *buffer, void (*swapFunc)(void *))
|
||||||
{
|
{
|
||||||
if (!fReadFrom)
|
if (!fReadFrom)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return fReadFrom->Read(name, foreignName, type, size, buffer, swapFunc);
|
return fReadFrom->Read(name, foreignName, type, size, buffer, swapFunc);
|
||||||
}
|
}
|
||||||
|
|
||||||
off_t
|
off_t
|
||||||
AttributeStreamNode::Write(const char *name, const char *foreignName, uint32 type,
|
AttributeStreamNode::Write(const char *name, const char *foreignName, uint32 type,
|
||||||
off_t size, const void *buffer)
|
off_t size, const void *buffer)
|
||||||
{
|
{
|
||||||
if (!fWriteTo)
|
if (!fWriteTo)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return fWriteTo->Write(name, foreignName, type, size, buffer);
|
return fWriteTo->Write(name, foreignName, type, size, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
AttributeStreamNode::Drive()
|
AttributeStreamNode::Drive()
|
||||||
{
|
{
|
||||||
ASSERT(CanFeed());
|
ASSERT(CanFeed());
|
||||||
@@ -200,17 +202,17 @@ AttributeStreamNode::Get()
|
|||||||
return fReadFrom->Get();
|
return fReadFrom->Get();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
AttributeStreamNode::Fill(char *buffer) const
|
AttributeStreamNode::Fill(char *buffer) const
|
||||||
{
|
{
|
||||||
ASSERT(fReadFrom);
|
ASSERT(fReadFrom);
|
||||||
return fReadFrom->Fill(buffer);
|
return fReadFrom->Fill(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
AttributeStreamNode::Start()
|
AttributeStreamNode::Start()
|
||||||
{
|
{
|
||||||
if (!fWriteTo)
|
if (!fWriteTo)
|
||||||
// we are at the head of the stream, start drivin'
|
// we are at the head of the stream, start drivin'
|
||||||
return Drive();
|
return Drive();
|
||||||
|
|
||||||
@@ -224,11 +226,11 @@ AttributeStreamNode::Detach()
|
|||||||
AttributeStreamNode *tmpTo = fWriteTo;
|
AttributeStreamNode *tmpTo = fWriteTo;
|
||||||
fReadFrom = NULL;
|
fReadFrom = NULL;
|
||||||
fWriteTo = NULL;
|
fWriteTo = NULL;
|
||||||
|
|
||||||
if (tmpFrom)
|
if (tmpFrom)
|
||||||
tmpFrom->Detach();
|
tmpFrom->Detach();
|
||||||
if (tmpTo)
|
if (tmpTo)
|
||||||
tmpTo->Detach();
|
tmpTo->Detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -244,21 +246,21 @@ AttributeStreamFileNode::AttributeStreamFileNode(BNode *node)
|
|||||||
ASSERT(fNode);
|
ASSERT(fNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AttributeStreamFileNode::Rewind()
|
AttributeStreamFileNode::Rewind()
|
||||||
{
|
{
|
||||||
_inherited::Rewind();
|
_inherited::Rewind();
|
||||||
fNode->RewindAttrs();
|
fNode->RewindAttrs();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AttributeStreamFileNode::SetTo(BNode *node)
|
AttributeStreamFileNode::SetTo(BNode *node)
|
||||||
{
|
{
|
||||||
fNode = node;
|
fNode = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
off_t
|
off_t
|
||||||
AttributeStreamFileNode::Contains(const char *name, uint32 type)
|
AttributeStreamFileNode::Contains(const char *name, uint32 type)
|
||||||
{
|
{
|
||||||
ASSERT(fNode);
|
ASSERT(fNode);
|
||||||
@@ -272,13 +274,13 @@ AttributeStreamFileNode::Contains(const char *name, uint32 type)
|
|||||||
return info.size;
|
return info.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
off_t
|
off_t
|
||||||
AttributeStreamFileNode::Read(const char *name, const char *foreignName, uint32 type,
|
AttributeStreamFileNode::Read(const char *name, const char *foreignName, uint32 type,
|
||||||
off_t size, void *buffer, void (*swapFunc)(void *))
|
off_t size, void *buffer, void (*swapFunc)(void *))
|
||||||
{
|
{
|
||||||
if (name && fNode->ReadAttr(name, type, 0, buffer, (size_t)size) == size)
|
if (name && fNode->ReadAttr(name, type, 0, buffer, (size_t)size) == size)
|
||||||
return size;
|
return size;
|
||||||
|
|
||||||
// didn't find the attribute under the native name, try the foreign name
|
// didn't find the attribute under the native name, try the foreign name
|
||||||
if (foreignName && fNode->ReadAttr(foreignName, type, 0, buffer, (size_t)size) == size) {
|
if (foreignName && fNode->ReadAttr(foreignName, type, 0, buffer, (size_t)size) == size) {
|
||||||
// foreign attribute, swap the data
|
// foreign attribute, swap the data
|
||||||
@@ -289,7 +291,7 @@ AttributeStreamFileNode::Read(const char *name, const char *foreignName, uint32
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
off_t
|
off_t
|
||||||
AttributeStreamFileNode::Write(const char *name, const char *foreignName, uint32 type,
|
AttributeStreamFileNode::Write(const char *name, const char *foreignName, uint32 type,
|
||||||
off_t size, const void *buffer)
|
off_t size, const void *buffer)
|
||||||
{
|
{
|
||||||
@@ -300,11 +302,11 @@ AttributeStreamFileNode::Write(const char *name, const char *foreignName, uint32
|
|||||||
// the write operation worked fine, remove the foreign attribute
|
// the write operation worked fine, remove the foreign attribute
|
||||||
// to not let stale data hang around
|
// to not let stale data hang around
|
||||||
fNode->RemoveAttr(foreignName);
|
fNode->RemoveAttr(foreignName);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
AttributeStreamFileNode::Drive()
|
AttributeStreamFileNode::Drive()
|
||||||
{
|
{
|
||||||
ASSERT(fNode);
|
ASSERT(fNode);
|
||||||
@@ -330,7 +332,7 @@ AttributeStreamFileNode::Get()
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
AttributeStreamFileNode::Fill(char *buffer) const
|
AttributeStreamFileNode::Fill(char *buffer) const
|
||||||
{
|
{
|
||||||
ASSERT(fNode);
|
ASSERT(fNode);
|
||||||
@@ -350,7 +352,7 @@ AttributeStreamFileNode::Next()
|
|||||||
attr_info info;
|
attr_info info;
|
||||||
if (fNode->GetAttrInfo(attrName, &info) != B_OK)
|
if (fNode->GetAttrInfo(attrName, &info) != B_OK)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
fCurrentAttr.SetTo(attrName, info);
|
fCurrentAttr.SetTo(attrName, info);
|
||||||
return &fCurrentAttr;
|
return &fCurrentAttr;
|
||||||
}
|
}
|
||||||
@@ -362,13 +364,13 @@ AttributeStreamMemoryNode::AttributeStreamMemoryNode()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AttributeStreamMemoryNode::MakeEmpty()
|
AttributeStreamMemoryNode::MakeEmpty()
|
||||||
{
|
{
|
||||||
fAttributes.MakeEmpty();
|
fAttributes.MakeEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AttributeStreamMemoryNode::Rewind()
|
AttributeStreamMemoryNode::Rewind()
|
||||||
{
|
{
|
||||||
_inherited::Rewind();
|
_inherited::Rewind();
|
||||||
@@ -387,7 +389,7 @@ AttributeStreamMemoryNode::Find(const char *name, uint32 type) const
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
off_t
|
off_t
|
||||||
AttributeStreamMemoryNode::Contains(const char *name, uint32 type)
|
AttributeStreamMemoryNode::Contains(const char *name, uint32 type)
|
||||||
{
|
{
|
||||||
int32 index = Find(name, type);
|
int32 index = Find(name, type);
|
||||||
@@ -397,7 +399,7 @@ AttributeStreamMemoryNode::Contains(const char *name, uint32 type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
off_t
|
off_t
|
||||||
AttributeStreamMemoryNode::Read(const char *name, const char *DEBUG_ONLY(foreignName),
|
AttributeStreamMemoryNode::Read(const char *name, const char *DEBUG_ONLY(foreignName),
|
||||||
uint32 type, off_t bufferSize, void *buffer, void (*DEBUG_ONLY(swapFunc))(void *))
|
uint32 type, off_t bufferSize, void *buffer, void (*DEBUG_ONLY(swapFunc))(void *))
|
||||||
{
|
{
|
||||||
@@ -413,7 +415,7 @@ AttributeStreamMemoryNode::Read(const char *name, const char *DEBUG_ONLY(foreign
|
|||||||
off_t size = fReadFrom->Contains(name, type);
|
off_t size = fReadFrom->Contains(name, type);
|
||||||
if (!size)
|
if (!size)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
attrNode = BufferingGet(name, type, size);
|
attrNode = BufferingGet(name, type, size);
|
||||||
if (!attrNode)
|
if (!attrNode)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -422,12 +424,12 @@ AttributeStreamMemoryNode::Read(const char *name, const char *DEBUG_ONLY(foreign
|
|||||||
|
|
||||||
if (attrNode->fAttr.Size() > bufferSize)
|
if (attrNode->fAttr.Size() > bufferSize)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
memcpy(buffer, attrNode->fData, (size_t)attrNode->fAttr.Size());
|
memcpy(buffer, attrNode->fData, (size_t)attrNode->fAttr.Size());
|
||||||
return attrNode->fAttr.Size();
|
return attrNode->fAttr.Size();
|
||||||
}
|
}
|
||||||
|
|
||||||
off_t
|
off_t
|
||||||
AttributeStreamMemoryNode::Write(const char *name, const char *, uint32 type,
|
AttributeStreamMemoryNode::Write(const char *name, const char *, uint32 type,
|
||||||
off_t size, const void *buffer)
|
off_t size, const void *buffer)
|
||||||
{
|
{
|
||||||
@@ -439,15 +441,15 @@ AttributeStreamMemoryNode::Write(const char *name, const char *, uint32 type,
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
AttributeStreamMemoryNode::Drive()
|
AttributeStreamMemoryNode::Drive()
|
||||||
{
|
{
|
||||||
if (!_inherited::Drive())
|
if (!_inherited::Drive())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
while (BufferingGet())
|
while (BufferingGet())
|
||||||
;
|
;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -471,7 +473,7 @@ AttributeStreamMemoryNode::BufferingGet()
|
|||||||
{
|
{
|
||||||
if (!fReadFrom)
|
if (!fReadFrom)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
const AttributeInfo *attr = fReadFrom->Next();
|
const AttributeInfo *attr = fReadFrom->Next();
|
||||||
if (!attr)
|
if (!attr)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -500,7 +502,7 @@ AttributeStreamMemoryNode::Get()
|
|||||||
return fAttributes.ItemAt(fCurrentIndex)->fData;
|
return fAttributes.ItemAt(fCurrentIndex)->fData;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
AttributeStreamMemoryNode::Fill(char *buffer) const
|
AttributeStreamMemoryNode::Fill(char *buffer) const
|
||||||
{
|
{
|
||||||
ASSERT(fCurrentIndex < fAttributes.CountItems());
|
ASSERT(fCurrentIndex < fAttributes.CountItems());
|
||||||
@@ -519,17 +521,17 @@ AttributeStreamTemplateNode::AttributeStreamTemplateNode(const AttributeTemplate
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
off_t
|
off_t
|
||||||
AttributeStreamTemplateNode::Contains(const char *name, uint32 type)
|
AttributeStreamTemplateNode::Contains(const char *name, uint32 type)
|
||||||
{
|
{
|
||||||
int32 index = Find(name, type);
|
int32 index = Find(name, type);
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return fAttributes[index].fSize;
|
return fAttributes[index].fSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AttributeStreamTemplateNode::Rewind()
|
AttributeStreamTemplateNode::Rewind()
|
||||||
{
|
{
|
||||||
fCurrentIndex = -1;
|
fCurrentIndex = -1;
|
||||||
@@ -556,7 +558,7 @@ AttributeStreamTemplateNode::Get()
|
|||||||
return fAttributes[fCurrentIndex].fBits;
|
return fAttributes[fCurrentIndex].fBits;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
AttributeStreamTemplateNode::Fill(char *buffer) const
|
AttributeStreamTemplateNode::Fill(char *buffer) const
|
||||||
{
|
{
|
||||||
ASSERT(fCurrentIndex < fCount);
|
ASSERT(fCurrentIndex < fCount);
|
||||||
@@ -565,18 +567,18 @@ AttributeStreamTemplateNode::Fill(char *buffer) const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32
|
int32
|
||||||
AttributeStreamTemplateNode::Find(const char *name, uint32 type) const
|
AttributeStreamTemplateNode::Find(const char *name, uint32 type) const
|
||||||
{
|
{
|
||||||
for (int32 index = 0; index < fCount; index++)
|
for (int32 index = 0; index < fCount; index++)
|
||||||
if (fAttributes[index].fAttributeType == type &&
|
if (fAttributes[index].fAttributeType == type &&
|
||||||
strcmp(name, fAttributes[index].fAttributeName) == 0)
|
strcmp(name, fAttributes[index].fAttributeName) == 0)
|
||||||
return index;
|
return index;
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
AttributeStreamFilterNode::Reject(const char *, uint32 , off_t )
|
AttributeStreamFilterNode::Reject(const char *, uint32 , off_t )
|
||||||
{
|
{
|
||||||
// simple pass everything filter
|
// simple pass everything filter
|
||||||
@@ -600,43 +602,43 @@ AttributeStreamFilterNode::Next()
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
off_t
|
off_t
|
||||||
AttributeStreamFilterNode::Contains(const char *name, uint32 type)
|
AttributeStreamFilterNode::Contains(const char *name, uint32 type)
|
||||||
{
|
{
|
||||||
if (!fReadFrom)
|
if (!fReadFrom)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
off_t size = fReadFrom->Contains(name, type);
|
off_t size = fReadFrom->Contains(name, type);
|
||||||
|
|
||||||
if (!Reject(name, type, size))
|
if (!Reject(name, type, size))
|
||||||
return size;
|
return size;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
off_t
|
off_t
|
||||||
AttributeStreamFilterNode::Read(const char *name, const char *foreignName, uint32 type,
|
AttributeStreamFilterNode::Read(const char *name, const char *foreignName, uint32 type,
|
||||||
off_t size, void *buffer, void (*swapFunc)(void *))
|
off_t size, void *buffer, void (*swapFunc)(void *))
|
||||||
{
|
{
|
||||||
if (!fReadFrom)
|
if (!fReadFrom)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!Reject(name, type, size))
|
if (!Reject(name, type, size))
|
||||||
return fReadFrom->Read(name, foreignName, type, size, buffer, swapFunc);
|
return fReadFrom->Read(name, foreignName, type, size, buffer, swapFunc);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
off_t
|
off_t
|
||||||
AttributeStreamFilterNode::Write(const char *name, const char *foreignName, uint32 type,
|
AttributeStreamFilterNode::Write(const char *name, const char *foreignName, uint32 type,
|
||||||
off_t size, const void *buffer)
|
off_t size, const void *buffer)
|
||||||
{
|
{
|
||||||
if (!fWriteTo)
|
if (!fWriteTo)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!Reject(name, type, size))
|
if (!Reject(name, type, size))
|
||||||
return fWriteTo->Write(name, foreignName, type, size, buffer);
|
return fWriteTo->Write(name, foreignName, type, size, buffer);
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -646,7 +648,7 @@ NamesToAcceptAttrFilter::NamesToAcceptAttrFilter(const char **nameList)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
NamesToAcceptAttrFilter::Reject(const char *name, uint32 , off_t )
|
NamesToAcceptAttrFilter::Reject(const char *name, uint32 , off_t )
|
||||||
{
|
{
|
||||||
for (int32 index = 0; ;index++) {
|
for (int32 index = 0; ;index++) {
|
||||||
@@ -679,7 +681,7 @@ SelectiveAttributeTransformer::~SelectiveAttributeTransformer()
|
|||||||
delete [] fTransformedBuffers.ItemAt(index);
|
delete [] fTransformedBuffers.ItemAt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SelectiveAttributeTransformer::Rewind()
|
SelectiveAttributeTransformer::Rewind()
|
||||||
{
|
{
|
||||||
for (int32 index = fTransformedBuffers.CountItems() - 1; index >= 0; index--)
|
for (int32 index = fTransformedBuffers.CountItems() - 1; index >= 0; index--)
|
||||||
@@ -689,13 +691,13 @@ SelectiveAttributeTransformer::Rewind()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
off_t
|
off_t
|
||||||
SelectiveAttributeTransformer::Read(const char *name, const char *foreignName,
|
SelectiveAttributeTransformer::Read(const char *name, const char *foreignName,
|
||||||
uint32 type, off_t size, void *buffer, void (*swapFunc)(void *))
|
uint32 type, off_t size, void *buffer, void (*swapFunc)(void *))
|
||||||
{
|
{
|
||||||
if (!fReadFrom)
|
if (!fReadFrom)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
off_t result = fReadFrom->Read(name, foreignName, type, size, buffer, swapFunc);
|
off_t result = fReadFrom->Read(name, foreignName, type, size, buffer, swapFunc);
|
||||||
|
|
||||||
if (WillTransform(name, type, size, (const char *)buffer))
|
if (WillTransform(name, type, size, (const char *)buffer))
|
||||||
@@ -704,21 +706,21 @@ SelectiveAttributeTransformer::Read(const char *name, const char *foreignName,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SelectiveAttributeTransformer::WillTransform(const char *name, uint32 , off_t ,
|
SelectiveAttributeTransformer::WillTransform(const char *name, uint32 , off_t ,
|
||||||
const char *) const
|
const char *) const
|
||||||
{
|
{
|
||||||
return strcmp(name, fAttributeNameToTransform) == 0;
|
return strcmp(name, fAttributeNameToTransform) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SelectiveAttributeTransformer::ApplyTransformer(const char *name, uint32 type, off_t size,
|
SelectiveAttributeTransformer::ApplyTransformer(const char *name, uint32 type, off_t size,
|
||||||
char *data)
|
char *data)
|
||||||
{
|
{
|
||||||
return (fTransformFunc)(name, type, size, data, fTransformParams);
|
return (fTransformFunc)(name, type, size, data, fTransformParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
SelectiveAttributeTransformer::CopyAndApplyTransformer(const char *name, uint32 type,
|
SelectiveAttributeTransformer::CopyAndApplyTransformer(const char *name, uint32 type,
|
||||||
off_t size, const char *data)
|
off_t size, const char *data)
|
||||||
{
|
{
|
||||||
@@ -751,15 +753,15 @@ SelectiveAttributeTransformer::Get()
|
|||||||
{
|
{
|
||||||
if (!fReadFrom)
|
if (!fReadFrom)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
const char *result = fReadFrom->Get();
|
const char *result = fReadFrom->Get();
|
||||||
|
|
||||||
if (!WillTransform(fCurrentAttr.Name(), fCurrentAttr.Type(), fCurrentAttr.Size(), result))
|
if (!WillTransform(fCurrentAttr.Name(), fCurrentAttr.Type(), fCurrentAttr.Size(), result))
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
char *transformedData = CopyAndApplyTransformer(fCurrentAttr.Name(), fCurrentAttr.Type(),
|
char *transformedData = CopyAndApplyTransformer(fCurrentAttr.Name(), fCurrentAttr.Type(),
|
||||||
fCurrentAttr.Size(), result);
|
fCurrentAttr.Size(), result);
|
||||||
|
|
||||||
// enlist for proper disposal when our job is done
|
// enlist for proper disposal when our job is done
|
||||||
if (transformedData) {
|
if (transformedData) {
|
||||||
fTransformedBuffers.AddItem(transformedData);
|
fTransformedBuffers.AddItem(transformedData);
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ All rights reserved.
|
|||||||
|
|
||||||
#include "AutoMounter.h"
|
#include "AutoMounter.h"
|
||||||
|
|
||||||
|
#include <Debug.h>
|
||||||
|
|
||||||
#include "AutoLock.h"
|
#include "AutoLock.h"
|
||||||
#include "AutoMounterSettings.h"
|
#include "AutoMounterSettings.h"
|
||||||
#include "Commands.h"
|
#include "Commands.h"
|
||||||
@@ -1021,7 +1023,7 @@ UnmountIfMatchingID(Partition *partition, void *castToParams)
|
|||||||
text << "To unmount " << partition->VolumeName() << " some query "
|
text << "To unmount " << partition->VolumeName() << " some query "
|
||||||
"windows have to be closed. Would you like to close the query "
|
"windows have to be closed. Would you like to close the query "
|
||||||
"windows?";
|
"windows?";
|
||||||
BAlert* alert = new BAlert("", text.String(), "Cancel",
|
BAlert* alert = new BAlert("", text.String(), "Cancel",
|
||||||
"Close and unmount", NULL, B_WIDTH_FROM_LABEL);
|
"Close and unmount", NULL, B_WIDTH_FROM_LABEL);
|
||||||
alert->SetShortcut(0, B_ESCAPE);
|
alert->SetShortcut(0, B_ESCAPE);
|
||||||
if (alert->Go() == 0)
|
if (alert->Go() == 0)
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ BImageResources::BImageResources(void *memAddr)
|
|||||||
name += ".rsrc";
|
name += ".rsrc";
|
||||||
BFile file(name.String(), B_READ_ONLY);
|
BFile file(name.String(), B_READ_ONLY);
|
||||||
#endif
|
#endif
|
||||||
if (file.InitCheck() == B_OK)
|
if (file.InitCheck() == B_OK)
|
||||||
fResources.SetTo(&file);
|
fResources.SetTo(&file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -105,7 +105,7 @@ BImageResources::FinishResources(BResources *res) const
|
|||||||
|
|
||||||
const void *
|
const void *
|
||||||
BImageResources::LoadResource(type_code type, int32 id, size_t *out_size) const
|
BImageResources::LoadResource(type_code type, int32 id, size_t *out_size) const
|
||||||
{
|
{
|
||||||
// Serialize execution.
|
// Serialize execution.
|
||||||
// Looks like BResources is not really thread safe. We should
|
// Looks like BResources is not really thread safe. We should
|
||||||
// clean that up in the future and remove the locking from here.
|
// clean that up in the future and remove the locking from here.
|
||||||
@@ -196,14 +196,14 @@ BImageResources::GetIconResource(int32 id, const uint8** iconData,
|
|||||||
image_id
|
image_id
|
||||||
BImageResources::find_image(void *memAddr) const
|
BImageResources::find_image(void *memAddr) const
|
||||||
{
|
{
|
||||||
image_info info;
|
image_info info;
|
||||||
int32 cookie = 0;
|
int32 cookie = 0;
|
||||||
while (get_next_image_info(0, &cookie, &info) == B_OK)
|
while (get_next_image_info(0, &cookie, &info) == B_OK)
|
||||||
if ((info.text <= memAddr && (((uint8 *)info.text)+info.text_size) > memAddr)
|
if ((info.text <= memAddr && (((uint8 *)info.text)+info.text_size) > memAddr)
|
||||||
||(info.data <= memAddr && (((uint8 *)info.data)+info.data_size) > memAddr))
|
||(info.data <= memAddr && (((uint8 *)info.data)+info.data_size) > memAddr))
|
||||||
// Found the image.
|
// Found the image.
|
||||||
return info.id;
|
return info.id;
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,7 +242,7 @@ BImageResources::GetBitmapResource(type_code type, int32 id, BBitmap **out) cons
|
|||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static BLocker resLock;
|
static BLocker resLock;
|
||||||
static BImageResources *resources = NULL;
|
static BImageResources *resources = NULL;
|
||||||
|
|||||||
@@ -32,12 +32,13 @@ names are registered trademarks or trademarks of their respective holders.
|
|||||||
All rights reserved.
|
All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Beep.h>
|
|
||||||
|
|
||||||
#include "FilePermissionsView.h"
|
#include "FilePermissionsView.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <Beep.h>
|
||||||
|
|
||||||
|
|
||||||
const uint32 kPermissionsChanged = 'prch';
|
const uint32 kPermissionsChanged = 'prch';
|
||||||
const uint32 kNewOwnerEntered = 'nwow';
|
const uint32 kNewOwnerEntered = 'nwow';
|
||||||
@@ -181,7 +182,7 @@ FilePermissionsView::ModelChanged(Model *model)
|
|||||||
fExecuteUserCheckBox->Show();
|
fExecuteUserCheckBox->Show();
|
||||||
fExecuteGroupCheckBox->Show();
|
fExecuteGroupCheckBox->Show();
|
||||||
fExecuteOtherCheckBox->Show();
|
fExecuteOtherCheckBox->Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node.GetPermissions(&perms) == B_OK) {
|
if (node.GetPermissions(&perms) == B_OK) {
|
||||||
fReadUserCheckBox->SetValue((int32)(perms & S_IRUSR));
|
fReadUserCheckBox->SetValue((int32)(perms & S_IRUSR));
|
||||||
@@ -205,9 +206,9 @@ FilePermissionsView::ModelChanged(Model *model)
|
|||||||
user << "root";
|
user << "root";
|
||||||
else
|
else
|
||||||
user << nodeOwner;
|
user << nodeOwner;
|
||||||
fOwnerTextControl->SetText(user.String());
|
fOwnerTextControl->SetText(user.String());
|
||||||
} else
|
} else
|
||||||
fOwnerTextControl->SetText("Unknown");
|
fOwnerTextControl->SetText("Unknown");
|
||||||
|
|
||||||
if (node.GetGroup(&nodeGroup) == B_OK) {
|
if (node.GetGroup(&nodeGroup) == B_OK) {
|
||||||
BString group;
|
BString group;
|
||||||
@@ -218,9 +219,9 @@ FilePermissionsView::ModelChanged(Model *model)
|
|||||||
group << "0";
|
group << "0";
|
||||||
else
|
else
|
||||||
group << nodeGroup;
|
group << nodeGroup;
|
||||||
fGroupTextControl->SetText(group.String());
|
fGroupTextControl->SetText(group.String());
|
||||||
} else
|
} else
|
||||||
fGroupTextControl->SetText("Unknown");
|
fGroupTextControl->SetText("Unknown");
|
||||||
|
|
||||||
// Unless we're root, only allow the owner to transfer the ownership,
|
// Unless we're root, only allow the owner to transfer the ownership,
|
||||||
// i.e. disable text controls if uid:s doesn't match:
|
// i.e. disable text controls if uid:s doesn't match:
|
||||||
@@ -276,11 +277,11 @@ FilePermissionsView::MessageReceived(BMessage *message)
|
|||||||
|
|
||||||
BNode node(fModel->EntryRef());
|
BNode node(fModel->EntryRef());
|
||||||
|
|
||||||
if (node.InitCheck() == B_OK)
|
if (node.InitCheck() == B_OK)
|
||||||
node.SetPermissions(newPermissions);
|
node.SetPermissions(newPermissions);
|
||||||
else {
|
else {
|
||||||
ModelChanged(fModel);
|
ModelChanged(fModel);
|
||||||
beep();
|
beep();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -294,11 +295,11 @@ FilePermissionsView::MessageReceived(BMessage *message)
|
|||||||
node.SetOwner(owner);
|
node.SetOwner(owner);
|
||||||
else {
|
else {
|
||||||
ModelChanged(fModel);
|
ModelChanged(fModel);
|
||||||
beep();
|
beep();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ModelChanged(fModel);
|
ModelChanged(fModel);
|
||||||
beep();
|
beep();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -312,11 +313,11 @@ FilePermissionsView::MessageReceived(BMessage *message)
|
|||||||
node.SetGroup(group);
|
node.SetGroup(group);
|
||||||
else {
|
else {
|
||||||
ModelChanged(fModel);
|
ModelChanged(fModel);
|
||||||
beep();
|
beep();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ModelChanged(fModel);
|
ModelChanged(fModel);
|
||||||
beep();
|
beep();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
+141
-141
@@ -127,7 +127,7 @@ IconCacheEntry::~IconCacheEntry()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
IconCacheEntry::SetAliasFor(const SharedIconCache *sharedCache,
|
IconCacheEntry::SetAliasFor(const SharedIconCache *sharedCache,
|
||||||
const SharedCacheEntry *entry)
|
const SharedCacheEntry *entry)
|
||||||
{
|
{
|
||||||
@@ -138,7 +138,7 @@ IconCacheEntry::SetAliasFor(const SharedIconCache *sharedCache,
|
|||||||
|
|
||||||
IconCacheEntry *
|
IconCacheEntry *
|
||||||
IconCacheEntry::ResolveIfAlias(const SharedIconCache *sharedCache)
|
IconCacheEntry::ResolveIfAlias(const SharedIconCache *sharedCache)
|
||||||
{
|
{
|
||||||
return sharedCache->ResolveIfAlias(this);
|
return sharedCache->ResolveIfAlias(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,7 +154,7 @@ IconCacheEntry::ResolveIfAlias(const SharedIconCache *sharedCache,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
IconCacheEntry::CanConstructBitmap(IconDrawMode mode, icon_size) const
|
IconCacheEntry::CanConstructBitmap(IconDrawMode mode, icon_size) const
|
||||||
{
|
{
|
||||||
if (mode == kSelected)
|
if (mode == kSelected)
|
||||||
@@ -165,7 +165,7 @@ IconCacheEntry::CanConstructBitmap(IconDrawMode mode, icon_size) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
IconCacheEntry::HaveIconBitmap(IconDrawMode mode, icon_size size) const
|
IconCacheEntry::HaveIconBitmap(IconDrawMode mode, icon_size size) const
|
||||||
{
|
{
|
||||||
ASSERT(mode == kSelected || mode == kNormalIcon);
|
ASSERT(mode == kSelected || mode == kNormalIcon);
|
||||||
@@ -193,7 +193,7 @@ IconCacheEntry::IconForMode(IconDrawMode mode, icon_size size) const
|
|||||||
{
|
{
|
||||||
ASSERT(mode == kSelected || mode == kNormalIcon);
|
ASSERT(mode == kSelected || mode == kNormalIcon);
|
||||||
// for now only
|
// for now only
|
||||||
|
|
||||||
if (mode == kNormalIcon) {
|
if (mode == kNormalIcon) {
|
||||||
if (size == B_MINI_ICON)
|
if (size == B_MINI_ICON)
|
||||||
return fMiniIcon;
|
return fMiniIcon;
|
||||||
@@ -209,7 +209,7 @@ IconCacheEntry::IconForMode(IconDrawMode mode, icon_size size) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
IconCacheEntry::IconHitTest(BPoint where, IconDrawMode mode, icon_size size) const
|
IconCacheEntry::IconHitTest(BPoint where, IconDrawMode mode, icon_size size) const
|
||||||
{
|
{
|
||||||
ASSERT(where.x < size && where.y < size);
|
ASSERT(where.x < size && where.y < size);
|
||||||
@@ -249,7 +249,7 @@ IconCacheEntry::ConstructBitmap(BBitmap *constructFrom, IconDrawMode requestedMo
|
|||||||
// for now
|
// for now
|
||||||
if (requestedMode == kSelected && constructFromMode == kNormalIcon)
|
if (requestedMode == kSelected && constructFromMode == kNormalIcon)
|
||||||
return IconCache::sIconCache->MakeSelectedIcon(constructFrom, size, lazyBitmap);
|
return IconCache::sIconCache->MakeSelectedIcon(constructFrom, size, lazyBitmap);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,7 +277,7 @@ IconCacheEntry::AlternateModeForIconConstructing(IconDrawMode requestedMode,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
IconCacheEntry::SetIcon(BBitmap *bitmap, IconDrawMode mode, icon_size size,
|
IconCacheEntry::SetIcon(BBitmap *bitmap, IconDrawMode mode, icon_size size,
|
||||||
bool /*create*/)
|
bool /*create*/)
|
||||||
{
|
{
|
||||||
@@ -318,7 +318,7 @@ IconCache::GetIconForPreferredApp(const char *fileTypeSignature,
|
|||||||
{
|
{
|
||||||
ASSERT(fSharedCache.IsLocked());
|
ASSERT(fSharedCache.IsLocked());
|
||||||
|
|
||||||
if (!preferredApp[0])
|
if (!preferredApp[0])
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
@@ -329,7 +329,7 @@ IconCache::GetIconForPreferredApp(const char *fileTypeSignature,
|
|||||||
PRINT(("File %s; Line %d # looking for %s, type %s, found %x\n",
|
PRINT(("File %s; Line %d # looking for %s, type %s, found %x\n",
|
||||||
__FILE__, __LINE__, preferredApp, fileTypeSignature, entry));
|
__FILE__, __LINE__, preferredApp, fileTypeSignature, entry));
|
||||||
#endif
|
#endif
|
||||||
if (entry->HaveIconBitmap(mode, size))
|
if (entry->HaveIconBitmap(mode, size))
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -343,7 +343,7 @@ IconCache::GetIconForPreferredApp(const char *fileTypeSignature,
|
|||||||
BString signature(fileTypeSignature);
|
BString signature(fileTypeSignature);
|
||||||
signature.ToLower();
|
signature.ToLower();
|
||||||
if (preferredAppType.GetIconForType(signature.String(), lazyBitmap->Get(),
|
if (preferredAppType.GetIconForType(signature.String(), lazyBitmap->Get(),
|
||||||
size) != B_OK)
|
size) != B_OK)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
BBitmap *bitmap = lazyBitmap->Adopt();
|
BBitmap *bitmap = lazyBitmap->Adopt();
|
||||||
@@ -377,7 +377,7 @@ IconCache::GetIconFromMetaMime(const char *fileType, IconDrawMode mode,
|
|||||||
if (entry) {
|
if (entry) {
|
||||||
entry = entry->ResolveIfAlias(&fSharedCache, entry);
|
entry = entry->ResolveIfAlias(&fSharedCache, entry);
|
||||||
// metamime defines an icon and we have it cached
|
// metamime defines an icon and we have it cached
|
||||||
if (entry->HaveIconBitmap(mode, size))
|
if (entry->HaveIconBitmap(mode, size))
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -389,7 +389,7 @@ IconCache::GetIconFromMetaMime(const char *fileType, IconDrawMode mode,
|
|||||||
// try getting the icon directly from the metamime
|
// try getting the icon directly from the metamime
|
||||||
if (mime.GetIcon(lazyBitmap->Get(), size) != B_OK) {
|
if (mime.GetIcon(lazyBitmap->Get(), size) != B_OK) {
|
||||||
// try getting it from the preferred app of this type
|
// try getting it from the preferred app of this type
|
||||||
char preferredAppSig[B_MIME_TYPE_LENGTH];
|
char preferredAppSig[B_MIME_TYPE_LENGTH];
|
||||||
if (mime.GetPreferredApp(preferredAppSig) != B_OK)
|
if (mime.GetPreferredApp(preferredAppSig) != B_OK)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@@ -399,8 +399,8 @@ IconCache::GetIconFromMetaMime(const char *fileType, IconDrawMode mode,
|
|||||||
|
|
||||||
// look for icon defined by preferred app from metamime
|
// look for icon defined by preferred app from metamime
|
||||||
aliasTo = (SharedCacheEntry *)GetIconForPreferredApp(fileType,
|
aliasTo = (SharedCacheEntry *)GetIconForPreferredApp(fileType,
|
||||||
preferredAppSig, mode, size, lazyBitmap, aliasTo);
|
preferredAppSig, mode, size, lazyBitmap, aliasTo);
|
||||||
|
|
||||||
if (aliasTo == NULL)
|
if (aliasTo == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@@ -422,7 +422,7 @@ IconCache::GetIconFromMetaMime(const char *fileType, IconDrawMode mode,
|
|||||||
PRINT_ADD_ITEM(("File %s; Line %d # adding entry for type %s\n",
|
PRINT_ADD_ITEM(("File %s; Line %d # adding entry for type %s\n",
|
||||||
__FILE__, __LINE__, fileType));
|
__FILE__, __LINE__, fileType));
|
||||||
entry = fSharedCache.AddItem(fileType);
|
entry = fSharedCache.AddItem(fileType);
|
||||||
}
|
}
|
||||||
entry->SetIcon(bitmap, kNormalIcon, size);
|
entry->SetIcon(bitmap, kNormalIcon, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -488,8 +488,8 @@ IconCache::GetIconFromFileTypes(ModelNodeLazyOpener *modelOpener,
|
|||||||
entry = GetIconFromMetaMime(superTypeFileType, mode, size,
|
entry = GetIconFromMetaMime(superTypeFileType, mode, size,
|
||||||
lazyBitmap, entry);
|
lazyBitmap, entry);
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
else
|
else
|
||||||
PRINT(("File %s; Line %d # failed to get supertype for type %s\n",
|
PRINT(("File %s; Line %d # failed to get supertype for type %s\n",
|
||||||
__FILE__, __LINE__, fileType));
|
__FILE__, __LINE__, fileType));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -499,16 +499,16 @@ IconCache::GetIconFromFileTypes(ModelNodeLazyOpener *modelOpener,
|
|||||||
if (nodePreferredApp[0]) {
|
if (nodePreferredApp[0]) {
|
||||||
// we got a miss using GetIconForPreferredApp before, cache this
|
// we got a miss using GetIconForPreferredApp before, cache this
|
||||||
// fileType/preferredApp combo with an aliased entry
|
// fileType/preferredApp combo with an aliased entry
|
||||||
|
|
||||||
// make an aliased entry so that the next time we get a
|
// make an aliased entry so that the next time we get a
|
||||||
// hit and substitute a generic icon right away
|
// hit and substitute a generic icon right away
|
||||||
|
|
||||||
PRINT_ADD_ITEM(("File %s; Line %d # adding entry as alias for preferredApp %s, type %s\n",
|
PRINT_ADD_ITEM(("File %s; Line %d # adding entry as alias for preferredApp %s, type %s\n",
|
||||||
__FILE__, __LINE__, nodePreferredApp, fileType));
|
__FILE__, __LINE__, nodePreferredApp, fileType));
|
||||||
IconCacheEntry *aliasedEntry = fSharedCache.AddItem((SharedCacheEntry **)&entry,
|
IconCacheEntry *aliasedEntry = fSharedCache.AddItem((SharedCacheEntry **)&entry,
|
||||||
fileType, nodePreferredApp);
|
fileType, nodePreferredApp);
|
||||||
aliasedEntry->SetAliasFor(&fSharedCache, (SharedCacheEntry *)entry);
|
aliasedEntry->SetAliasFor(&fSharedCache, (SharedCacheEntry *)entry);
|
||||||
// OK to cast here, have a runtime check
|
// OK to cast here, have a runtime check
|
||||||
source = kPreferredAppForNode;
|
source = kPreferredAppForNode;
|
||||||
// set source as preferred for node, so that next time we get a hit in
|
// set source as preferred for node, so that next time we get a hit in
|
||||||
// the initial find that uses GetIconForPreferredApp
|
// the initial find that uses GetIconForPreferredApp
|
||||||
@@ -529,7 +529,7 @@ IconCache::GetVolumeIcon(AutoLock<SimpleIconCache> *nodeCacheLocker,
|
|||||||
AutoLock<SimpleIconCache> **resultingOpenCache,
|
AutoLock<SimpleIconCache> **resultingOpenCache,
|
||||||
Model *model, IconSource &source,
|
Model *model, IconSource &source,
|
||||||
IconDrawMode mode, icon_size size, LazyBitmapAllocator *lazyBitmap)
|
IconDrawMode mode, icon_size size, LazyBitmapAllocator *lazyBitmap)
|
||||||
{
|
{
|
||||||
*resultingOpenCache = nodeCacheLocker;
|
*resultingOpenCache = nodeCacheLocker;
|
||||||
nodeCacheLocker->Lock();
|
nodeCacheLocker->Lock();
|
||||||
|
|
||||||
@@ -548,7 +548,7 @@ IconCache::GetVolumeIcon(AutoLock<SimpleIconCache> *nodeCacheLocker,
|
|||||||
sharedCacheLocker->Lock();
|
sharedCacheLocker->Lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry->HaveIconBitmap(mode, size))
|
if (entry->HaveIconBitmap(mode, size))
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -568,7 +568,7 @@ IconCache::GetVolumeIcon(AutoLock<SimpleIconCache> *nodeCacheLocker,
|
|||||||
entry = fNodeCache.AddItem(model->NodeRef());
|
entry = fNodeCache.AddItem(model->NodeRef());
|
||||||
}
|
}
|
||||||
entry->SetIcon(lazyBitmap->Adopt(), kNormalIcon, size);
|
entry->SetIcon(lazyBitmap->Adopt(), kNormalIcon, size);
|
||||||
} else if (volume.GetIcon(lazyBitmap->Get(), size) == B_OK) {
|
} else if (volume.GetIcon(lazyBitmap->Get(), size) == B_OK) {
|
||||||
// Ask the device for an icon
|
// Ask the device for an icon
|
||||||
BBitmap *bitmap = lazyBitmap->Adopt();
|
BBitmap *bitmap = lazyBitmap->Adopt();
|
||||||
ASSERT(bitmap);
|
ASSERT(bitmap);
|
||||||
@@ -605,10 +605,10 @@ IconCache::GetRootIcon(AutoLock<SimpleIconCache> *,
|
|||||||
AutoLock<SimpleIconCache> **resultingOpenCache,
|
AutoLock<SimpleIconCache> **resultingOpenCache,
|
||||||
Model *, IconSource &source, IconDrawMode mode,
|
Model *, IconSource &source, IconDrawMode mode,
|
||||||
icon_size size, LazyBitmapAllocator *lazyBitmap)
|
icon_size size, LazyBitmapAllocator *lazyBitmap)
|
||||||
{
|
{
|
||||||
*resultingOpenCache = sharedCacheLocker;
|
*resultingOpenCache = sharedCacheLocker;
|
||||||
(*resultingOpenCache)->Lock();
|
(*resultingOpenCache)->Lock();
|
||||||
|
|
||||||
source = kTrackerSupplied;
|
source = kTrackerSupplied;
|
||||||
return GetIconFromMetaMime(B_ROOT_MIMETYPE, mode, size, lazyBitmap, 0);
|
return GetIconFromMetaMime(B_ROOT_MIMETYPE, mode, size, lazyBitmap, 0);
|
||||||
}
|
}
|
||||||
@@ -639,7 +639,7 @@ IconCache::GetWellKnownIcon(AutoLock<SimpleIconCache> *,
|
|||||||
entry = fSharedCache.FindItem(type.String());
|
entry = fSharedCache.FindItem(type.String());
|
||||||
if (entry) {
|
if (entry) {
|
||||||
entry = entry->ResolveIfAlias(&fSharedCache, entry);
|
entry = entry->ResolveIfAlias(&fSharedCache, entry);
|
||||||
if (entry->HaveIconBitmap(mode, size))
|
if (entry->HaveIconBitmap(mode, size))
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -732,7 +732,7 @@ IconCache::GetNodeIcon(ModelNodeLazyOpener *modelOpener,
|
|||||||
Model *model, IconSource &source,
|
Model *model, IconSource &source,
|
||||||
IconDrawMode mode, icon_size size,
|
IconDrawMode mode, icon_size size,
|
||||||
LazyBitmapAllocator *lazyBitmap, IconCacheEntry *entry, bool permanent)
|
LazyBitmapAllocator *lazyBitmap, IconCacheEntry *entry, bool permanent)
|
||||||
{
|
{
|
||||||
*resultingOpenCache = nodeCacheLocker;
|
*resultingOpenCache = nodeCacheLocker;
|
||||||
(*resultingOpenCache)->Lock();
|
(*resultingOpenCache)->Lock();
|
||||||
|
|
||||||
@@ -747,12 +747,12 @@ IconCache::GetNodeIcon(ModelNodeLazyOpener *modelOpener,
|
|||||||
// an app
|
// an app
|
||||||
if (model->IsExecutable())
|
if (model->IsExecutable())
|
||||||
file = dynamic_cast<BFile *>(model->Node());
|
file = dynamic_cast<BFile *>(model->Node());
|
||||||
|
|
||||||
PRINT_DISK_HITS(("File %s; Line %d # hitting disk for node %s\n",
|
PRINT_DISK_HITS(("File %s; Line %d # hitting disk for node %s\n",
|
||||||
__FILE__, __LINE__, model->Name()));
|
__FILE__, __LINE__, model->Name()));
|
||||||
|
|
||||||
status_t result;
|
status_t result;
|
||||||
if (file)
|
if (file)
|
||||||
result = GetAppIconFromAttr(file, lazyBitmap->Get(), size);
|
result = GetAppIconFromAttr(file, lazyBitmap->Get(), size);
|
||||||
else
|
else
|
||||||
result = GetFileIconFromAttr(model->Node(), lazyBitmap->Get(), size);
|
result = GetFileIconFromAttr(model->Node(), lazyBitmap->Get(), size);
|
||||||
@@ -773,7 +773,7 @@ IconCache::GetNodeIcon(ModelNodeLazyOpener *modelOpener,
|
|||||||
source = kNode;
|
source = kNode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
(*resultingOpenCache)->Unlock();
|
(*resultingOpenCache)->Unlock();
|
||||||
*resultingOpenCache = NULL;
|
*resultingOpenCache = NULL;
|
||||||
@@ -794,7 +794,7 @@ IconCache::GetGenericIcon(AutoLock<SimpleIconCache> *sharedCacheLocker,
|
|||||||
Model *model, IconSource &source,
|
Model *model, IconSource &source,
|
||||||
IconDrawMode mode, icon_size size,
|
IconDrawMode mode, icon_size size,
|
||||||
LazyBitmapAllocator *lazyBitmap, IconCacheEntry *entry)
|
LazyBitmapAllocator *lazyBitmap, IconCacheEntry *entry)
|
||||||
{
|
{
|
||||||
*resultingOpenCache = sharedCacheLocker;
|
*resultingOpenCache = sharedCacheLocker;
|
||||||
(*resultingOpenCache)->Lock();
|
(*resultingOpenCache)->Lock();
|
||||||
|
|
||||||
@@ -803,7 +803,7 @@ IconCache::GetGenericIcon(AutoLock<SimpleIconCache> *sharedCacheLocker,
|
|||||||
|
|
||||||
if (!entry)
|
if (!entry)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// make an aliased entry so that the next time we get a
|
// make an aliased entry so that the next time we get a
|
||||||
// hit and substitute a generic icon right away
|
// hit and substitute a generic icon right away
|
||||||
PRINT_ADD_ITEM(("File %s; Line %d # adding entry for preferredApp %s, type %s\n",
|
PRINT_ADD_ITEM(("File %s; Line %d # adding entry for preferredApp %s, type %s\n",
|
||||||
@@ -826,13 +826,13 @@ IconCache::GetFallbackIcon(AutoLock<SimpleIconCache> *sharedCacheLocker,
|
|||||||
AutoLock<SimpleIconCache> **resultingOpenCache,
|
AutoLock<SimpleIconCache> **resultingOpenCache,
|
||||||
Model *model, IconDrawMode mode, icon_size size,
|
Model *model, IconDrawMode mode, icon_size size,
|
||||||
LazyBitmapAllocator *lazyBitmap, IconCacheEntry *entry)
|
LazyBitmapAllocator *lazyBitmap, IconCacheEntry *entry)
|
||||||
{
|
{
|
||||||
*resultingOpenCache = sharedCacheLocker;
|
*resultingOpenCache = sharedCacheLocker;
|
||||||
(*resultingOpenCache)->Lock();
|
(*resultingOpenCache)->Lock();
|
||||||
|
|
||||||
entry = fSharedCache.AddItem(model->MimeType(),
|
entry = fSharedCache.AddItem(model->MimeType(),
|
||||||
model->PreferredAppSignature());
|
model->PreferredAppSignature());
|
||||||
|
|
||||||
BBitmap *bitmap = lazyBitmap->Get();
|
BBitmap *bitmap = lazyBitmap->Get();
|
||||||
GetTrackerResources()->GetIconResource(kResFileIcon, size, bitmap);
|
GetTrackerResources()->GetIconResource(kResFileIcon, size, bitmap);
|
||||||
entry->SetIcon(lazyBitmap->Adopt(), kNormalIcon, size);
|
entry->SetIcon(lazyBitmap->Adopt(), kNormalIcon, size);
|
||||||
@@ -867,10 +867,10 @@ IconCache::Preload(AutoLock<SimpleIconCache> *nodeCacheLocker,
|
|||||||
// closing it when we are done
|
// closing it when we are done
|
||||||
LazyBitmapAllocator lazyBitmap(size);
|
LazyBitmapAllocator lazyBitmap(size);
|
||||||
// lazyBitmap manages bitmap allocation and freeing if needed
|
// lazyBitmap manages bitmap allocation and freeing if needed
|
||||||
|
|
||||||
IconSource source = model->IconFrom();
|
IconSource source = model->IconFrom();
|
||||||
if (source == kUnknownSource || source == kUnknownNotFromNode) {
|
if (source == kUnknownSource || source == kUnknownNotFromNode) {
|
||||||
|
|
||||||
// fish for special first models and handle them appropriately
|
// fish for special first models and handle them appropriately
|
||||||
if (model->IsVolume()) {
|
if (model->IsVolume()) {
|
||||||
// volume may use specialized icon in the volume node
|
// volume may use specialized icon in the volume node
|
||||||
@@ -896,26 +896,26 @@ IconCache::Preload(AutoLock<SimpleIconCache> *nodeCacheLocker,
|
|||||||
entry = GetNodeIcon(&modelOpener, nodeCacheLocker,
|
entry = GetNodeIcon(&modelOpener, nodeCacheLocker,
|
||||||
&resultingOpenCache, model, source,
|
&resultingOpenCache, model, source,
|
||||||
mode, size, &lazyBitmap, entry, permanent);
|
mode, size, &lazyBitmap, entry, permanent);
|
||||||
|
|
||||||
|
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
// no node icon, look for file type based one
|
// no node icon, look for file type based one
|
||||||
modelOpener.OpenNode();
|
modelOpener.OpenNode();
|
||||||
// use file types to get the icon
|
// use file types to get the icon
|
||||||
resultingOpenCache = sharedCacheLocker;
|
resultingOpenCache = sharedCacheLocker;
|
||||||
resultingOpenCache->Lock();
|
resultingOpenCache->Lock();
|
||||||
|
|
||||||
entry = GetIconFromFileTypes(&modelOpener, source, mode, size,
|
entry = GetIconFromFileTypes(&modelOpener, source, mode, size,
|
||||||
&lazyBitmap, 0);
|
&lazyBitmap, 0);
|
||||||
|
|
||||||
if (!entry) // we don't have an icon, go with the generic
|
if (!entry) // we don't have an icon, go with the generic
|
||||||
entry = GetGenericIcon(sharedCacheLocker, &resultingOpenCache,
|
entry = GetGenericIcon(sharedCacheLocker, &resultingOpenCache,
|
||||||
model, source, mode, size, &lazyBitmap, entry);
|
model, source, mode, size, &lazyBitmap, entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// update the icon source
|
// update the icon source
|
||||||
model->SetIconFrom(source);
|
model->SetIconFrom(source);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// we already know where the icon should come from,
|
// we already know where the icon should come from,
|
||||||
// use shortcuts to get it
|
// use shortcuts to get it
|
||||||
@@ -923,7 +923,7 @@ IconCache::Preload(AutoLock<SimpleIconCache> *nodeCacheLocker,
|
|||||||
case kNode:
|
case kNode:
|
||||||
resultingOpenCache = nodeCacheLocker;
|
resultingOpenCache = nodeCacheLocker;
|
||||||
resultingOpenCache->Lock();
|
resultingOpenCache->Lock();
|
||||||
|
|
||||||
entry = GetNodeIcon(&modelOpener, nodeCacheLocker,
|
entry = GetNodeIcon(&modelOpener, nodeCacheLocker,
|
||||||
&resultingOpenCache, model, source, mode,
|
&resultingOpenCache, model, source, mode,
|
||||||
size, &lazyBitmap, entry, permanent);
|
size, &lazyBitmap, entry, permanent);
|
||||||
@@ -976,7 +976,7 @@ IconCache::Preload(AutoLock<SimpleIconCache> *nodeCacheLocker,
|
|||||||
&lazyBitmap, 0);
|
&lazyBitmap, 0);
|
||||||
ASSERT(!entry || entry->HaveIconBitmap(mode, size));
|
ASSERT(!entry || entry->HaveIconBitmap(mode, size));
|
||||||
|
|
||||||
if (!entry || !entry->HaveIconBitmap(mode, size))
|
if (!entry || !entry->HaveIconBitmap(mode, size))
|
||||||
// we don't have an icon, go with the generic
|
// we don't have an icon, go with the generic
|
||||||
entry = GetGenericIcon(sharedCacheLocker, &resultingOpenCache,
|
entry = GetGenericIcon(sharedCacheLocker, &resultingOpenCache,
|
||||||
model, source, mode, size, &lazyBitmap, entry);
|
model, source, mode, size, &lazyBitmap, entry);
|
||||||
@@ -998,7 +998,7 @@ IconCache::Preload(AutoLock<SimpleIconCache> *nodeCacheLocker,
|
|||||||
TRESPASS();
|
TRESPASS();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!entry || !entry->HaveIconBitmap(mode, size)) {
|
if (!entry || !entry->HaveIconBitmap(mode, size)) {
|
||||||
// we don't have an icon, go with the generic
|
// we don't have an icon, go with the generic
|
||||||
PRINT(("icon cache complete miss, falling back on generic icon for %s\n",
|
PRINT(("icon cache complete miss, falling back on generic icon for %s\n",
|
||||||
@@ -1007,7 +1007,7 @@ IconCache::Preload(AutoLock<SimpleIconCache> *nodeCacheLocker,
|
|||||||
model, source, mode, size, &lazyBitmap, entry);
|
model, source, mode, size, &lazyBitmap, entry);
|
||||||
|
|
||||||
// we don't even have generic, something is really broken,
|
// we don't even have generic, something is really broken,
|
||||||
// go with hardcoded generic icon
|
// go with hardcoded generic icon
|
||||||
if (!entry || !entry->HaveIconBitmap(mode, size)) {
|
if (!entry || !entry->HaveIconBitmap(mode, size)) {
|
||||||
PRINT(("icon cache complete miss, falling back on generic icon for %s\n",
|
PRINT(("icon cache complete miss, falling back on generic icon for %s\n",
|
||||||
model->Name()));
|
model->Name()));
|
||||||
@@ -1020,9 +1020,9 @@ IconCache::Preload(AutoLock<SimpleIconCache> *nodeCacheLocker,
|
|||||||
model->SetIconFrom(kUnknownSource);
|
model->SetIconFrom(kUnknownSource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(entry && entry->HaveIconBitmap(mode, size));
|
ASSERT(entry && entry->HaveIconBitmap(mode, size));
|
||||||
|
|
||||||
if (resultingCache)
|
if (resultingCache)
|
||||||
*resultingCache = resultingOpenCache;
|
*resultingCache = resultingOpenCache;
|
||||||
|
|
||||||
@@ -1040,7 +1040,7 @@ IconCache::Draw(Model *model, BView *view, BPoint where, IconDrawMode mode,
|
|||||||
AutoLock<SimpleIconCache> nodeCacheLocker(&fNodeCache, false);
|
AutoLock<SimpleIconCache> nodeCacheLocker(&fNodeCache, false);
|
||||||
AutoLock<SimpleIconCache> sharedCacheLocker(&fSharedCache, false);
|
AutoLock<SimpleIconCache> sharedCacheLocker(&fSharedCache, false);
|
||||||
|
|
||||||
AutoLock<SimpleIconCache> *resultingCacheLocker;
|
AutoLock<SimpleIconCache> *resultingCacheLocker;
|
||||||
IconCacheEntry *entry = Preload(&nodeCacheLocker, &sharedCacheLocker,
|
IconCacheEntry *entry = Preload(&nodeCacheLocker, &sharedCacheLocker,
|
||||||
&resultingCacheLocker, model, mode, size, false);
|
&resultingCacheLocker, model, mode, size, false);
|
||||||
// Preload finds/creates the appropriate entry, locking down the
|
// Preload finds/creates the appropriate entry, locking down the
|
||||||
@@ -1054,21 +1054,21 @@ IconCache::Draw(Model *model, BView *view, BPoint where, IconDrawMode mode,
|
|||||||
// got the entry, now draw it
|
// got the entry, now draw it
|
||||||
resultingCacheLocker->LockedItem()->Draw(entry, view, where, mode,
|
resultingCacheLocker->LockedItem()->Draw(entry, view, where, mode,
|
||||||
size, async);
|
size, async);
|
||||||
|
|
||||||
// either of the two cache lockers that got locked down by this call get
|
// either of the two cache lockers that got locked down by this call get
|
||||||
// unlocked at this point
|
// unlocked at this point
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
IconCache::SyncDraw(Model *model, BView *view, BPoint where, IconDrawMode mode,
|
IconCache::SyncDraw(Model *model, BView *view, BPoint where, IconDrawMode mode,
|
||||||
icon_size size, void (*blitFunc)(BView *, BPoint, BBitmap *, void *),
|
icon_size size, void (*blitFunc)(BView *, BPoint, BBitmap *, void *),
|
||||||
void *passThruState)
|
void *passThruState)
|
||||||
{
|
{
|
||||||
AutoLock<SimpleIconCache> nodeCacheLocker(&fNodeCache, false);
|
AutoLock<SimpleIconCache> nodeCacheLocker(&fNodeCache, false);
|
||||||
AutoLock<SimpleIconCache> sharedCacheLocker(&fSharedCache, false);
|
AutoLock<SimpleIconCache> sharedCacheLocker(&fSharedCache, false);
|
||||||
|
|
||||||
AutoLock<SimpleIconCache> *resultingCacheLocker;
|
AutoLock<SimpleIconCache> *resultingCacheLocker;
|
||||||
IconCacheEntry *entry = Preload(&nodeCacheLocker, &sharedCacheLocker,
|
IconCacheEntry *entry = Preload(&nodeCacheLocker, &sharedCacheLocker,
|
||||||
&resultingCacheLocker, model, mode, size, false);
|
&resultingCacheLocker, model, mode, size, false);
|
||||||
|
|
||||||
@@ -1082,7 +1082,7 @@ IconCache::SyncDraw(Model *model, BView *view, BPoint where, IconDrawMode mode,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
IconCache::Preload(Model *model, IconDrawMode mode, icon_size size, bool permanent)
|
IconCache::Preload(Model *model, IconDrawMode mode, icon_size size, bool permanent)
|
||||||
{
|
{
|
||||||
AutoLock<SimpleIconCache> nodeCacheLocker(&fNodeCache, false);
|
AutoLock<SimpleIconCache> nodeCacheLocker(&fNodeCache, false);
|
||||||
@@ -1092,7 +1092,7 @@ IconCache::Preload(Model *model, IconDrawMode mode, icon_size size, bool permane
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
IconCache::Preload(const char *fileType, IconDrawMode mode, icon_size size)
|
IconCache::Preload(const char *fileType, IconDrawMode mode, icon_size size)
|
||||||
{
|
{
|
||||||
AutoLock<SimpleIconCache> sharedCacheLocker(&fSharedCache);
|
AutoLock<SimpleIconCache> sharedCacheLocker(&fSharedCache);
|
||||||
@@ -1106,14 +1106,14 @@ IconCache::Preload(const char *fileType, IconDrawMode mode, icon_size size)
|
|||||||
|
|
||||||
// try getting the icon from the preferred app for the signature
|
// try getting the icon from the preferred app for the signature
|
||||||
IconCacheEntry *entry = GetIconForPreferredApp(fileType, preferredAppSig,
|
IconCacheEntry *entry = GetIconForPreferredApp(fileType, preferredAppSig,
|
||||||
mode, size, &lazyBitmap, 0);
|
mode, size, &lazyBitmap, 0);
|
||||||
if (entry)
|
if (entry)
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|
||||||
// try getting the icon directly from the metamime
|
// try getting the icon directly from the metamime
|
||||||
result = mime.GetIcon(lazyBitmap.Get(), size);
|
result = mime.GetIcon(lazyBitmap.Get(), size);
|
||||||
|
|
||||||
if (result != B_OK)
|
if (result != B_OK)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
entry = fSharedCache.AddItem(fileType);
|
entry = fSharedCache.AddItem(fileType);
|
||||||
@@ -1133,24 +1133,24 @@ IconCache::Deleting(const Model *model)
|
|||||||
{
|
{
|
||||||
AutoLock<SimpleIconCache> lock(&fNodeCache);
|
AutoLock<SimpleIconCache> lock(&fNodeCache);
|
||||||
|
|
||||||
if (model->IconFrom() == kNode)
|
if (model->IconFrom() == kNode)
|
||||||
fNodeCache.Deleting(model->NodeRef());
|
fNodeCache.Deleting(model->NodeRef());
|
||||||
|
|
||||||
// don't care if the node uses the shared cache
|
// don't care if the node uses the shared cache
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
IconCache::Removing(const Model *model)
|
IconCache::Removing(const Model *model)
|
||||||
{
|
{
|
||||||
AutoLock<SimpleIconCache> lock(&fNodeCache);
|
AutoLock<SimpleIconCache> lock(&fNodeCache);
|
||||||
|
|
||||||
if (model->IconFrom() == kNode)
|
if (model->IconFrom() == kNode)
|
||||||
fNodeCache.Removing(model->NodeRef());
|
fNodeCache.Removing(model->NodeRef());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
IconCache::Deleting(const BView *view)
|
IconCache::Deleting(const BView *view)
|
||||||
{
|
{
|
||||||
AutoLock<SimpleIconCache> lock(&fNodeCache);
|
AutoLock<SimpleIconCache> lock(&fNodeCache);
|
||||||
@@ -1158,32 +1158,32 @@ IconCache::Deleting(const BView *view)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
IconCache::IconChanged(Model *model)
|
IconCache::IconChanged(Model *model)
|
||||||
{
|
{
|
||||||
AutoLock<SimpleIconCache> lock(&fNodeCache);
|
AutoLock<SimpleIconCache> lock(&fNodeCache);
|
||||||
|
|
||||||
if (model->IconFrom() == kNode || model->IconFrom() == kVolume)
|
if (model->IconFrom() == kNode || model->IconFrom() == kVolume)
|
||||||
fNodeCache.Deleting(model->NodeRef());
|
fNodeCache.Deleting(model->NodeRef());
|
||||||
|
|
||||||
model->ResetIconFrom();
|
model->ResetIconFrom();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
IconCache::IconChanged(const char *mimeType, const char *appSignature)
|
IconCache::IconChanged(const char *mimeType, const char *appSignature)
|
||||||
{
|
{
|
||||||
AutoLock<SimpleIconCache> sharedLock(&fSharedCache);
|
AutoLock<SimpleIconCache> sharedLock(&fSharedCache);
|
||||||
SharedCacheEntry *entry = fSharedCache.FindItem(mimeType, appSignature);
|
SharedCacheEntry *entry = fSharedCache.FindItem(mimeType, appSignature);
|
||||||
if (!entry)
|
if (!entry)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
AutoLock<SimpleIconCache> nodeLock(&fNodeCache);
|
AutoLock<SimpleIconCache> nodeLock(&fNodeCache);
|
||||||
|
|
||||||
entry = (SharedCacheEntry *)fSharedCache.ResolveIfAlias(entry);
|
entry = (SharedCacheEntry *)fSharedCache.ResolveIfAlias(entry);
|
||||||
ASSERT(entry);
|
ASSERT(entry);
|
||||||
int32 index = fSharedCache.EntryIndex(entry);
|
int32 index = fSharedCache.EntryIndex(entry);
|
||||||
|
|
||||||
fNodeCache.RemoveAliasesTo(index);
|
fNodeCache.RemoveAliasesTo(index);
|
||||||
fSharedCache.RemoveAliasesTo(index);
|
fSharedCache.RemoveAliasesTo(index);
|
||||||
|
|
||||||
@@ -1191,7 +1191,7 @@ IconCache::IconChanged(const char *mimeType, const char *appSignature)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BBitmap *
|
BBitmap *
|
||||||
IconCache::MakeSelectedIcon(const BBitmap *normal, icon_size size,
|
IconCache::MakeSelectedIcon(const BBitmap *normal, icon_size size,
|
||||||
LazyBitmapAllocator *lazyBitmap)
|
LazyBitmapAllocator *lazyBitmap)
|
||||||
{
|
{
|
||||||
@@ -1208,17 +1208,17 @@ DumpBitmap(const BBitmap *bitmap)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int32 length = bitmap->BitsLength();
|
int32 length = bitmap->BitsLength();
|
||||||
|
|
||||||
printf("data length %ld \n", length);
|
printf("data length %ld \n", length);
|
||||||
|
|
||||||
int32 columns = (int32)bitmap->Bounds().Width() + 1;
|
int32 columns = (int32)bitmap->Bounds().Width() + 1;
|
||||||
const unsigned char *bitPtr = (const unsigned char *)bitmap->Bits();
|
const unsigned char *bitPtr = (const unsigned char *)bitmap->Bits();
|
||||||
for (; length >= 0; length--) {
|
for (; length >= 0; length--) {
|
||||||
for (int32 columnIndex = 0; columnIndex < columns;
|
for (int32 columnIndex = 0; columnIndex < columns;
|
||||||
columnIndex++, length--)
|
columnIndex++, length--)
|
||||||
printf("%c%c", "0123456789ABCDEF"[(*bitPtr)/0x10],
|
printf("%c%c", "0123456789ABCDEF"[(*bitPtr)/0x10],
|
||||||
"0123456789ABCDEF"[(*bitPtr++)%0x10]);
|
"0123456789ABCDEF"[(*bitPtr++)%0x10]);
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
@@ -1242,7 +1242,7 @@ IconCache::InitHiliteTable()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BBitmap *
|
BBitmap *
|
||||||
IconCache::MakeTransformedIcon(const BBitmap* source, icon_size /*size*/,
|
IconCache::MakeTransformedIcon(const BBitmap* source, icon_size /*size*/,
|
||||||
int32 colorTransformTable[], LazyBitmapAllocator* lazyBitmap)
|
int32 colorTransformTable[], LazyBitmapAllocator* lazyBitmap)
|
||||||
{
|
{
|
||||||
@@ -1305,14 +1305,14 @@ IconCache::MakeTransformedIcon(const BBitmap* source, icon_size /*size*/,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
IconCache::IconHitTest(BPoint where, const Model *model, IconDrawMode mode,
|
IconCache::IconHitTest(BPoint where, const Model *model, IconDrawMode mode,
|
||||||
icon_size size)
|
icon_size size)
|
||||||
{
|
{
|
||||||
AutoLock<SimpleIconCache> nodeCacheLocker(&fNodeCache, false);
|
AutoLock<SimpleIconCache> nodeCacheLocker(&fNodeCache, false);
|
||||||
AutoLock<SimpleIconCache> sharedCacheLocker(&fSharedCache, false);
|
AutoLock<SimpleIconCache> sharedCacheLocker(&fSharedCache, false);
|
||||||
|
|
||||||
AutoLock<SimpleIconCache> *resultingCacheLocker;
|
AutoLock<SimpleIconCache> *resultingCacheLocker;
|
||||||
IconCacheEntry *entry = Preload(&nodeCacheLocker, &sharedCacheLocker,
|
IconCacheEntry *entry = Preload(&nodeCacheLocker, &sharedCacheLocker,
|
||||||
&resultingCacheLocker, const_cast<Model *>(model), mode, size, false);
|
&resultingCacheLocker, const_cast<Model *>(model), mode, size, false);
|
||||||
// Preload finds/creates the appropriate entry, locking down the
|
// Preload finds/creates the appropriate entry, locking down the
|
||||||
@@ -1325,7 +1325,7 @@ IconCache::IconHitTest(BPoint where, const Model *model, IconDrawMode mode,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
IconCacheEntry::RetireIcons(BObjectList<BBitmap> *retiredBitmapList)
|
IconCacheEntry::RetireIcons(BObjectList<BBitmap> *retiredBitmapList)
|
||||||
{
|
{
|
||||||
if (fLargeIcon) {
|
if (fLargeIcon) {
|
||||||
@@ -1344,7 +1344,7 @@ IconCacheEntry::RetireIcons(BObjectList<BBitmap> *retiredBitmapList)
|
|||||||
retiredBitmapList->AddItem(fHilitedMiniIcon);
|
retiredBitmapList->AddItem(fHilitedMiniIcon);
|
||||||
fHilitedMiniIcon = NULL;
|
fHilitedMiniIcon = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 count = retiredBitmapList->CountItems();
|
int32 count = retiredBitmapList->CountItems();
|
||||||
if (count > 10 * 1024) {
|
if (count > 10 * 1024) {
|
||||||
PRINT(("nuking old icons from the retired bitmap list\n"));
|
PRINT(("nuking old icons from the retired bitmap list\n"));
|
||||||
@@ -1378,7 +1378,7 @@ SharedIconCache::SharedIconCache()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SharedIconCache::Draw(IconCacheEntry *entry, BView *view, BPoint where,
|
SharedIconCache::Draw(IconCacheEntry *entry, BView *view, BPoint where,
|
||||||
IconDrawMode mode, icon_size size, bool async)
|
IconDrawMode mode, icon_size size, bool async)
|
||||||
{
|
{
|
||||||
@@ -1386,12 +1386,12 @@ SharedIconCache::Draw(IconCacheEntry *entry, BView *view, BPoint where,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SharedIconCache::Draw(IconCacheEntry *entry, BView *view, BPoint where,
|
SharedIconCache::Draw(IconCacheEntry *entry, BView *view, BPoint where,
|
||||||
IconDrawMode mode, icon_size size, void (*blitFunc)(BView *, BPoint,
|
IconDrawMode mode, icon_size size, void (*blitFunc)(BView *, BPoint,
|
||||||
BBitmap *, void *), void *passThruState)
|
BBitmap *, void *), void *passThruState)
|
||||||
{
|
{
|
||||||
((SharedCacheEntry *)entry)->Draw(view, where, mode, size,
|
((SharedCacheEntry *)entry)->Draw(view, where, mode, size,
|
||||||
blitFunc, passThruState);
|
blitFunc, passThruState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1408,14 +1408,14 @@ SharedIconCache::FindItem(const char *fileType, const char *appSignature) const
|
|||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
if (result->fFileType == fileType && result->fAppSignature == appSignature)
|
if (result->fFileType == fileType && result->fAppSignature == appSignature)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
if (result->fNext < 0)
|
if (result->fNext < 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
result = const_cast<SharedCacheEntry *>(&fElementArray.At(result->fNext));
|
result = const_cast<SharedCacheEntry *>(&fElementArray.At(result->fNext));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1430,7 +1430,7 @@ SharedIconCache::AddItem(const char *fileType, const char *appSignature)
|
|||||||
if (!fileType)
|
if (!fileType)
|
||||||
fileType = B_FILE_MIMETYPE;
|
fileType = B_FILE_MIMETYPE;
|
||||||
|
|
||||||
SharedCacheEntry *result = &fHashTable.Add(SharedCacheEntry::Hash(fileType,
|
SharedCacheEntry *result = fHashTable.Add(SharedCacheEntry::Hash(fileType,
|
||||||
appSignature));
|
appSignature));
|
||||||
result->SetTo(fileType, appSignature);
|
result->SetTo(fileType, appSignature);
|
||||||
return result;
|
return result;
|
||||||
@@ -1448,7 +1448,7 @@ SharedIconCache::AddItem(SharedCacheEntry **outstandingEntry, const char *fileTy
|
|||||||
if (!fileType)
|
if (!fileType)
|
||||||
fileType = B_FILE_MIMETYPE;
|
fileType = B_FILE_MIMETYPE;
|
||||||
|
|
||||||
SharedCacheEntry *result = &fHashTable.Add(SharedCacheEntry::Hash(fileType,
|
SharedCacheEntry *result = fHashTable.Add(SharedCacheEntry::Hash(fileType,
|
||||||
appSignature));
|
appSignature));
|
||||||
result->SetTo(fileType, appSignature);
|
result->SetTo(fileType, appSignature);
|
||||||
*outstandingEntry = fHashTable.ElementAt(entryToken);
|
*outstandingEntry = fHashTable.ElementAt(entryToken);
|
||||||
@@ -1457,7 +1457,7 @@ SharedIconCache::AddItem(SharedCacheEntry **outstandingEntry, const char *fileTy
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SharedIconCache::IconChanged(SharedCacheEntry *entry)
|
SharedIconCache::IconChanged(SharedCacheEntry *entry)
|
||||||
{
|
{
|
||||||
// by now there should be no aliases to entry, just remove entry
|
// by now there should be no aliases to entry, just remove entry
|
||||||
@@ -1468,7 +1468,7 @@ SharedIconCache::IconChanged(SharedCacheEntry *entry)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SharedIconCache::RemoveAliasesTo(int32 aliasIndex)
|
SharedIconCache::RemoveAliasesTo(int32 aliasIndex)
|
||||||
{
|
{
|
||||||
int32 count = fHashTable.VectorSize();
|
int32 count = fHashTable.VectorSize();
|
||||||
@@ -1480,7 +1480,7 @@ SharedIconCache::RemoveAliasesTo(int32 aliasIndex)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SharedIconCache::SetAliasFor(IconCacheEntry *alias, const SharedCacheEntry *original) const
|
SharedIconCache::SetAliasFor(IconCacheEntry *alias, const SharedCacheEntry *original) const
|
||||||
{
|
{
|
||||||
alias->fAliasForIndex = fHashTable.ElementIndex(original);
|
alias->fAliasForIndex = fHashTable.ElementIndex(original);
|
||||||
@@ -1501,7 +1501,7 @@ SharedCacheEntry::SharedCacheEntry(const char *fileType, const char *appSignatur
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SharedCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode, icon_size size,
|
SharedCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode, icon_size size,
|
||||||
bool async)
|
bool async)
|
||||||
{
|
{
|
||||||
@@ -1518,7 +1518,7 @@ SharedCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode, icon_size s
|
|||||||
} else {
|
} else {
|
||||||
view->SetDrawingMode(B_OP_OVER);
|
view->SetDrawingMode(B_OP_OVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (async)
|
if (async)
|
||||||
view->DrawBitmapAsync(bitmap, where);
|
view->DrawBitmapAsync(bitmap, where);
|
||||||
else
|
else
|
||||||
@@ -1528,26 +1528,26 @@ SharedCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode, icon_size s
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SharedCacheEntry::Draw(BView *view, BPoint where, IconDrawMode mode, icon_size size,
|
SharedCacheEntry::Draw(BView *view, BPoint where, IconDrawMode mode, icon_size size,
|
||||||
void (*blitFunc)(BView *, BPoint ,BBitmap *, void *), void *passThruState)
|
void (*blitFunc)(BView *, BPoint ,BBitmap *, void *), void *passThruState)
|
||||||
{
|
{
|
||||||
BBitmap *bitmap = IconForMode(mode, size);
|
BBitmap *bitmap = IconForMode(mode, size);
|
||||||
if (!bitmap)
|
if (!bitmap)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// if (bitmap->ColorSpace() == B_RGBA32) {
|
// if (bitmap->ColorSpace() == B_RGBA32) {
|
||||||
// view->SetDrawingMode(B_OP_ALPHA);
|
// view->SetDrawingMode(B_OP_ALPHA);
|
||||||
// view->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
|
// view->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
|
||||||
// } else {
|
// } else {
|
||||||
// view->SetDrawingMode(B_OP_OVER);
|
// view->SetDrawingMode(B_OP_OVER);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
(blitFunc)(view, where, bitmap, passThruState);
|
(blitFunc)(view, where, bitmap, passThruState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32
|
uint32
|
||||||
SharedCacheEntry::Hash(const char *fileType, const char *appSignature)
|
SharedCacheEntry::Hash(const char *fileType, const char *appSignature)
|
||||||
{
|
{
|
||||||
uint32 hash = HashString(fileType, 0);
|
uint32 hash = HashString(fileType, 0);
|
||||||
@@ -1558,7 +1558,7 @@ SharedCacheEntry::Hash(const char *fileType, const char *appSignature)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32
|
uint32
|
||||||
SharedCacheEntry::Hash() const
|
SharedCacheEntry::Hash() const
|
||||||
{
|
{
|
||||||
uint32 hash = HashString(fFileType.String(), 0);
|
uint32 hash = HashString(fFileType.String(), 0);
|
||||||
@@ -1569,14 +1569,14 @@ SharedCacheEntry::Hash() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SharedCacheEntry::operator==(const SharedCacheEntry &entry) const
|
SharedCacheEntry::operator==(const SharedCacheEntry &entry) const
|
||||||
{
|
{
|
||||||
return fFileType == entry.FileType() && fAppSignature == entry.AppSignature();
|
return fFileType == entry.FileType() && fAppSignature == entry.AppSignature();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SharedCacheEntry::SetTo(const char *fileType, const char *appSignature)
|
SharedCacheEntry::SetTo(const char *fileType, const char *appSignature)
|
||||||
{
|
{
|
||||||
fFileType = fileType;
|
fFileType = fileType;
|
||||||
@@ -1590,10 +1590,10 @@ SharedCacheEntryArray::SharedCacheEntryArray(int32 initialSize)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SharedCacheEntry *
|
SharedCacheEntry *
|
||||||
SharedCacheEntryArray::Add()
|
SharedCacheEntryArray::Add()
|
||||||
{
|
{
|
||||||
return &At(OpenHashElementArray<SharedCacheEntry>::Add());
|
return OpenHashElementArray<SharedCacheEntry>::Add();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1615,14 +1615,14 @@ NodeCacheEntry::NodeCacheEntry(const node_ref *node, bool permanent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
NodeCacheEntry::Draw(BView *view, BPoint where, IconDrawMode mode, icon_size size,
|
NodeCacheEntry::Draw(BView *view, BPoint where, IconDrawMode mode, icon_size size,
|
||||||
bool async)
|
bool async)
|
||||||
{
|
{
|
||||||
BBitmap *bitmap = IconForMode(mode, size);
|
BBitmap *bitmap = IconForMode(mode, size);
|
||||||
if (!bitmap)
|
if (!bitmap)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
drawing_mode oldMode = view->DrawingMode();
|
drawing_mode oldMode = view->DrawingMode();
|
||||||
|
|
||||||
if (bitmap->ColorSpace() == B_RGBA32) {
|
if (bitmap->ColorSpace() == B_RGBA32) {
|
||||||
@@ -1633,7 +1633,7 @@ NodeCacheEntry::Draw(BView *view, BPoint where, IconDrawMode mode, icon_size siz
|
|||||||
} else {
|
} else {
|
||||||
view->SetDrawingMode(B_OP_OVER);
|
view->SetDrawingMode(B_OP_OVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (false && async) {
|
if (false && async) {
|
||||||
TRESPASS();
|
TRESPASS();
|
||||||
// need to copy the bits first in here
|
// need to copy the bits first in here
|
||||||
@@ -1645,21 +1645,21 @@ NodeCacheEntry::Draw(BView *view, BPoint where, IconDrawMode mode, icon_size siz
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
NodeCacheEntry::Draw(BView *view, BPoint where, IconDrawMode mode, icon_size size,
|
NodeCacheEntry::Draw(BView *view, BPoint where, IconDrawMode mode, icon_size size,
|
||||||
void (*blitFunc)(BView *, BPoint ,BBitmap *, void *), void *passThruState)
|
void (*blitFunc)(BView *, BPoint ,BBitmap *, void *), void *passThruState)
|
||||||
{
|
{
|
||||||
BBitmap *bitmap = IconForMode(mode, size);
|
BBitmap *bitmap = IconForMode(mode, size);
|
||||||
if (!bitmap)
|
if (!bitmap)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// if (bitmap->ColorSpace() == B_RGBA32) {
|
// if (bitmap->ColorSpace() == B_RGBA32) {
|
||||||
// view->SetDrawingMode(B_OP_ALPHA);
|
// view->SetDrawingMode(B_OP_ALPHA);
|
||||||
// view->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
|
// view->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
|
||||||
// } else {
|
// } else {
|
||||||
// view->SetDrawingMode(B_OP_OVER);
|
// view->SetDrawingMode(B_OP_OVER);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
(blitFunc)(view, where, bitmap, passThruState);
|
(blitFunc)(view, where, bitmap, passThruState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1671,42 +1671,42 @@ NodeCacheEntry::Node() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32
|
uint32
|
||||||
NodeCacheEntry::Hash() const
|
NodeCacheEntry::Hash() const
|
||||||
{
|
{
|
||||||
return Hash(&fRef);
|
return Hash(&fRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32
|
uint32
|
||||||
NodeCacheEntry::Hash(const node_ref *node)
|
NodeCacheEntry::Hash(const node_ref *node)
|
||||||
{
|
{
|
||||||
return node->device ^ ((uint32 *)&node->node)[0] ^ ((uint32 *)&node->node)[1];
|
return node->device ^ ((uint32 *)&node->node)[0] ^ ((uint32 *)&node->node)[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
NodeCacheEntry::operator==(const NodeCacheEntry &entry) const
|
NodeCacheEntry::operator==(const NodeCacheEntry &entry) const
|
||||||
{
|
{
|
||||||
return fRef == entry.fRef;
|
return fRef == entry.fRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
NodeCacheEntry::SetTo(const node_ref *node)
|
NodeCacheEntry::SetTo(const node_ref *node)
|
||||||
{
|
{
|
||||||
fRef = *node;
|
fRef = *node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
NodeCacheEntry::Permanent() const
|
NodeCacheEntry::Permanent() const
|
||||||
{
|
{
|
||||||
return fPermanent;
|
return fPermanent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
NodeCacheEntry::MakePermanent()
|
NodeCacheEntry::MakePermanent()
|
||||||
{
|
{
|
||||||
fPermanent = true;
|
fPermanent = true;
|
||||||
@@ -1731,7 +1731,7 @@ NodeIconCache::NodeIconCache()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
NodeIconCache::Draw(IconCacheEntry *entry, BView *view, BPoint where,
|
NodeIconCache::Draw(IconCacheEntry *entry, BView *view, BPoint where,
|
||||||
IconDrawMode mode, icon_size size, bool async)
|
IconDrawMode mode, icon_size size, bool async)
|
||||||
{
|
{
|
||||||
@@ -1740,12 +1740,12 @@ NodeIconCache::Draw(IconCacheEntry *entry, BView *view, BPoint where,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
NodeIconCache::Draw(IconCacheEntry *entry, BView *view, BPoint where,
|
NodeIconCache::Draw(IconCacheEntry *entry, BView *view, BPoint where,
|
||||||
IconDrawMode mode, icon_size size, void (*blitFunc)(BView *, BPoint,
|
IconDrawMode mode, icon_size size, void (*blitFunc)(BView *, BPoint,
|
||||||
BBitmap *, void *), void *passThruState)
|
BBitmap *, void *), void *passThruState)
|
||||||
{
|
{
|
||||||
((NodeCacheEntry *)entry)->Draw(view, where, mode, size,
|
((NodeCacheEntry *)entry)->Draw(view, where, mode, size,
|
||||||
blitFunc, passThruState);
|
blitFunc, passThruState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1757,14 +1757,14 @@ NodeIconCache::FindItem(const node_ref *node) const
|
|||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
if (*result->Node() == *node)
|
if (*result->Node() == *node)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
if (result->fNext < 0)
|
if (result->fNext < 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
result = const_cast<NodeCacheEntry *>(&fElementArray.At(result->fNext));
|
result = const_cast<NodeCacheEntry *>(&fElementArray.At(result->fNext));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1775,7 +1775,7 @@ NodeIconCache::FindItem(const node_ref *node) const
|
|||||||
NodeCacheEntry *
|
NodeCacheEntry *
|
||||||
NodeIconCache::AddItem(const node_ref *node, bool permanent)
|
NodeIconCache::AddItem(const node_ref *node, bool permanent)
|
||||||
{
|
{
|
||||||
NodeCacheEntry *result = &fHashTable.Add(NodeCacheEntry::Hash(node));
|
NodeCacheEntry *result = fHashTable.Add(NodeCacheEntry::Hash(node));
|
||||||
result->SetTo(node);
|
result->SetTo(node);
|
||||||
if (permanent)
|
if (permanent)
|
||||||
result->MakePermanent();
|
result->MakePermanent();
|
||||||
@@ -1789,7 +1789,7 @@ NodeIconCache::AddItem(NodeCacheEntry **outstandingEntry, const node_ref *node)
|
|||||||
{
|
{
|
||||||
int32 entryToken = fHashTable.ElementIndex(*outstandingEntry);
|
int32 entryToken = fHashTable.ElementIndex(*outstandingEntry);
|
||||||
|
|
||||||
NodeCacheEntry *result = &fHashTable.Add(NodeCacheEntry::Hash(node));
|
NodeCacheEntry *result = fHashTable.Add(NodeCacheEntry::Hash(node));
|
||||||
result->SetTo(node);
|
result->SetTo(node);
|
||||||
*outstandingEntry = fHashTable.ElementAt(entryToken);
|
*outstandingEntry = fHashTable.ElementAt(entryToken);
|
||||||
|
|
||||||
@@ -1797,31 +1797,31 @@ NodeIconCache::AddItem(NodeCacheEntry **outstandingEntry, const node_ref *node)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
NodeIconCache::Deleting(const node_ref *node)
|
NodeIconCache::Deleting(const node_ref *node)
|
||||||
{
|
{
|
||||||
NodeCacheEntry *entry = FindItem(node);
|
NodeCacheEntry *entry = FindItem(node);
|
||||||
ASSERT(entry);
|
ASSERT(entry);
|
||||||
if (!entry || entry->Permanent())
|
if (!entry || entry->Permanent())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fHashTable.Remove(entry);
|
fHashTable.Remove(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
NodeIconCache::Removing(const node_ref *node)
|
NodeIconCache::Removing(const node_ref *node)
|
||||||
{
|
{
|
||||||
NodeCacheEntry *entry = FindItem(node);
|
NodeCacheEntry *entry = FindItem(node);
|
||||||
ASSERT(entry);
|
ASSERT(entry);
|
||||||
if (!entry)
|
if (!entry)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fHashTable.Remove(entry);
|
fHashTable.Remove(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
NodeIconCache::Deleting(const BView *)
|
NodeIconCache::Deleting(const BView *)
|
||||||
{
|
{
|
||||||
#ifdef NODE_CACHE_ASYNC_DRAWS
|
#ifdef NODE_CACHE_ASYNC_DRAWS
|
||||||
@@ -1830,14 +1830,14 @@ NodeIconCache::Deleting(const BView *)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
NodeIconCache::IconChanged(const Model *model)
|
NodeIconCache::IconChanged(const Model *model)
|
||||||
{
|
{
|
||||||
Deleting(model->NodeRef());
|
Deleting(model->NodeRef());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
NodeIconCache::RemoveAliasesTo(int32 aliasIndex)
|
NodeIconCache::RemoveAliasesTo(int32 aliasIndex)
|
||||||
{
|
{
|
||||||
int32 count = fHashTable.VectorSize();
|
int32 count = fHashTable.VectorSize();
|
||||||
@@ -1861,7 +1861,7 @@ NodeCacheEntryArray::NodeCacheEntryArray(int32 initialSize)
|
|||||||
NodeCacheEntry *
|
NodeCacheEntry *
|
||||||
NodeCacheEntryArray::Add()
|
NodeCacheEntryArray::Add()
|
||||||
{
|
{
|
||||||
return &At(OpenHashElementArray<NodeCacheEntry>::Add());
|
return OpenHashElementArray<NodeCacheEntry>::Add();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1874,8 +1874,8 @@ SimpleIconCache::SimpleIconCache(const char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SimpleIconCache::Draw(IconCacheEntry *, BView *, BPoint, IconDrawMode ,
|
SimpleIconCache::Draw(IconCacheEntry *, BView *, BPoint, IconDrawMode ,
|
||||||
icon_size , bool )
|
icon_size , bool )
|
||||||
{
|
{
|
||||||
TRESPASS();
|
TRESPASS();
|
||||||
@@ -1883,7 +1883,7 @@ SimpleIconCache::Draw(IconCacheEntry *, BView *, BPoint, IconDrawMode ,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SimpleIconCache::Draw(IconCacheEntry *, BView *, BPoint, IconDrawMode, icon_size,
|
SimpleIconCache::Draw(IconCacheEntry *, BView *, BPoint, IconDrawMode, icon_size,
|
||||||
void(*)(BView *, BPoint, BBitmap *, void *), void *)
|
void(*)(BView *, BPoint, BBitmap *, void *), void *)
|
||||||
{
|
{
|
||||||
@@ -1892,21 +1892,21 @@ SimpleIconCache::Draw(IconCacheEntry *, BView *, BPoint, IconDrawMode, icon_size
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SimpleIconCache::Lock()
|
SimpleIconCache::Lock()
|
||||||
{
|
{
|
||||||
return fLock.Lock();
|
return fLock.Lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SimpleIconCache::Unlock()
|
SimpleIconCache::Unlock()
|
||||||
{
|
{
|
||||||
fLock.Unlock();
|
fLock.Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SimpleIconCache::IsLocked() const
|
SimpleIconCache::IsLocked() const
|
||||||
{
|
{
|
||||||
return fLock.IsLocked();
|
return fLock.IsLocked();
|
||||||
@@ -1948,7 +1948,7 @@ LazyBitmapAllocator::Adopt()
|
|||||||
{
|
{
|
||||||
if (!fBitmap)
|
if (!fBitmap)
|
||||||
Get();
|
Get();
|
||||||
|
|
||||||
BBitmap *result = fBitmap;
|
BBitmap *result = fBitmap;
|
||||||
fBitmap = NULL;
|
fBitmap = NULL;
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ All rights reserved.
|
|||||||
|
|
||||||
// MountMenu implements a context menu used for mounting/unmounting volumes
|
// MountMenu implements a context menu used for mounting/unmounting volumes
|
||||||
|
|
||||||
|
#include <Debug.h>
|
||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
#include <Mime.h>
|
#include <Mime.h>
|
||||||
#include <InterfaceDefs.h>
|
#include <InterfaceDefs.h>
|
||||||
|
|||||||
@@ -1,376 +0,0 @@
|
|||||||
/*
|
|
||||||
Open Tracker License
|
|
||||||
|
|
||||||
Terms and Conditions
|
|
||||||
|
|
||||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
|
||||||
|
|
||||||
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 applies to all licensees
|
|
||||||
and 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 TITLE, MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
BE INCORPORATED 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.
|
|
||||||
|
|
||||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
|
||||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
|
||||||
this Software without prior written authorization from Be Incorporated.
|
|
||||||
|
|
||||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
|
||||||
of Be Incorporated in the United States and other countries. Other brand product
|
|
||||||
names are registered trademarks or trademarks of their respective holders.
|
|
||||||
All rights reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Hash table with open addresssing
|
|
||||||
|
|
||||||
#ifndef __OPEN_HASH_TABLE__
|
|
||||||
#define __OPEN_HASH_TABLE__
|
|
||||||
|
|
||||||
#include <new>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
namespace BPrivate {
|
|
||||||
|
|
||||||
template <class Element>
|
|
||||||
class ElementVector {
|
|
||||||
// element vector for OpenHashTable needs to implement this
|
|
||||||
// interface
|
|
||||||
public:
|
|
||||||
Element &At(int32 index);
|
|
||||||
Element *Add();
|
|
||||||
int32 IndexOf(const Element &) const;
|
|
||||||
void Remove(int32 index);
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpenHashElement {
|
|
||||||
public:
|
|
||||||
uint32 Hash() const;
|
|
||||||
bool operator==(const OpenHashElement &) const;
|
|
||||||
void Adopt(OpenHashElement &);
|
|
||||||
// low overhead copy, original element is in undefined state
|
|
||||||
// after call (calls Adopt on BString members, etc.)
|
|
||||||
int32 fNext;
|
|
||||||
};
|
|
||||||
|
|
||||||
const uint32 kPrimes [] = {
|
|
||||||
509, 1021, 2039, 4093, 8191, 16381, 32749, 65521, 131071, 262139,
|
|
||||||
524287, 1048573, 2097143, 4194301, 8388593, 16777213, 33554393, 67108859,
|
|
||||||
134217689, 268435399, 536870909, 1073741789, 2147483647, 0
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class Element, class ElementVec = ElementVector<Element> >
|
|
||||||
class OpenHashTable {
|
|
||||||
public:
|
|
||||||
OpenHashTable(int32 minSize, ElementVec *elementVector = 0);
|
|
||||||
// it is up to the subclass of OpenHashTable to supply
|
|
||||||
// elementVector
|
|
||||||
~OpenHashTable();
|
|
||||||
|
|
||||||
void SetElementVector(ElementVec *elementVector);
|
|
||||||
|
|
||||||
Element *FindFirst(uint32 elementHash) const;
|
|
||||||
Element &Add(uint32 elementHash);
|
|
||||||
|
|
||||||
void Remove(Element *);
|
|
||||||
|
|
||||||
// when calling Add, any outstanding element pointer may become
|
|
||||||
// invalid; to deal with this, get the element index and restore
|
|
||||||
// it after the add
|
|
||||||
int32 ElementIndex(const Element *) const;
|
|
||||||
Element *ElementAt(int32 index) const;
|
|
||||||
|
|
||||||
int32 VectorSize() const;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
static int32 OptimalSize(int32 minSize);
|
|
||||||
|
|
||||||
int32 fArraySize;
|
|
||||||
int32 *fHashArray;
|
|
||||||
ElementVec *fElementVector;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
template <class Element>
|
|
||||||
class OpenHashElementArray : public ElementVector<Element> {
|
|
||||||
// this is a straightforward implementation of an element vector
|
|
||||||
// deleting is handled by linking deleted elements into a free list
|
|
||||||
// the vector never shrinks
|
|
||||||
public:
|
|
||||||
OpenHashElementArray(int32 initialSize);
|
|
||||||
~OpenHashElementArray();
|
|
||||||
|
|
||||||
Element &At(int32 index);
|
|
||||||
const Element &At(int32 index) const;
|
|
||||||
int32 Add(const Element &);
|
|
||||||
int32 Add();
|
|
||||||
void Remove(int32 index);
|
|
||||||
int32 IndexOf(const Element &) const;
|
|
||||||
int32 Size() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
Element *fData;
|
|
||||||
int32 fSize;
|
|
||||||
int32 fNextFree;
|
|
||||||
int32 fNextDeleted;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//--- inline implementation --------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
template<class Element, class ElementVec>
|
|
||||||
OpenHashTable<Element, ElementVec>::OpenHashTable(int32 minSize,ElementVec *elementVector)
|
|
||||||
:
|
|
||||||
fArraySize(OptimalSize(minSize)),
|
|
||||||
fElementVector(elementVector)
|
|
||||||
{
|
|
||||||
fHashArray = new int32[fArraySize];
|
|
||||||
for (int32 index = 0; index < fArraySize; index++)
|
|
||||||
fHashArray[index] = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Element, class ElementVec>
|
|
||||||
OpenHashTable<Element, ElementVec>::~OpenHashTable()
|
|
||||||
{
|
|
||||||
delete fHashArray;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Element, class ElementVec>
|
|
||||||
int32
|
|
||||||
OpenHashTable<Element, ElementVec>::OptimalSize(int32 minSize)
|
|
||||||
{
|
|
||||||
for (int32 index = 0; ; index++)
|
|
||||||
if (!kPrimes[index] || kPrimes[index] >= (uint32)minSize)
|
|
||||||
return (int32)kPrimes[index];
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Element, class ElementVec>
|
|
||||||
Element *
|
|
||||||
OpenHashTable<Element, ElementVec>::FindFirst(uint32 hash) const
|
|
||||||
{
|
|
||||||
ASSERT(fElementVector);
|
|
||||||
hash %= fArraySize;
|
|
||||||
if (fHashArray[hash] < 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return &fElementVector->At(fHashArray[hash]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Element, class ElementVec>
|
|
||||||
int32
|
|
||||||
OpenHashTable<Element, ElementVec>::ElementIndex(const Element *element) const
|
|
||||||
{
|
|
||||||
return fElementVector->IndexOf(*element);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Element, class ElementVec>
|
|
||||||
Element *
|
|
||||||
OpenHashTable<Element, ElementVec>::ElementAt(int32 index) const
|
|
||||||
{
|
|
||||||
return &fElementVector->At(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Element, class ElementVec>
|
|
||||||
int32
|
|
||||||
OpenHashTable<Element, ElementVec>::VectorSize() const
|
|
||||||
{
|
|
||||||
return fElementVector->Size();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Element, class ElementVec>
|
|
||||||
Element &
|
|
||||||
OpenHashTable<Element, ElementVec>::Add(uint32 hash)
|
|
||||||
{
|
|
||||||
ASSERT(fElementVector);
|
|
||||||
hash %= fArraySize;
|
|
||||||
Element &result = *fElementVector->Add();
|
|
||||||
result.fNext = fHashArray[hash];
|
|
||||||
fHashArray[hash] = fElementVector->IndexOf(result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Element, class ElementVec>
|
|
||||||
void
|
|
||||||
OpenHashTable<Element, ElementVec>::Remove(Element *element)
|
|
||||||
{
|
|
||||||
uint32 hash = element->Hash() % fArraySize;
|
|
||||||
int32 next = fHashArray[hash];
|
|
||||||
ASSERT(next >= 0);
|
|
||||||
|
|
||||||
if (&fElementVector->At(next) == element) {
|
|
||||||
fHashArray[hash] = element->fNext;
|
|
||||||
fElementVector->Remove(next);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int32 index = next; index >= 0; ) {
|
|
||||||
// look for an existing match in table
|
|
||||||
int32 next = fElementVector->At(index).fNext;
|
|
||||||
if (next < 0) {
|
|
||||||
TRESPASS();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (&fElementVector->At(next) == element) {
|
|
||||||
fElementVector->At(index).fNext = element->fNext;
|
|
||||||
fElementVector->Remove(next);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
index = next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Element, class ElementVec>
|
|
||||||
void
|
|
||||||
OpenHashTable<Element, ElementVec>::SetElementVector(ElementVec *elementVector)
|
|
||||||
{
|
|
||||||
fElementVector = elementVector;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Element>
|
|
||||||
OpenHashElementArray<Element>::OpenHashElementArray(int32 initialSize)
|
|
||||||
:
|
|
||||||
fSize(initialSize),
|
|
||||||
fNextFree(0),
|
|
||||||
fNextDeleted(-1)
|
|
||||||
{
|
|
||||||
fData = (Element *)calloc((size_t)initialSize , sizeof(Element));
|
|
||||||
if (!fData)
|
|
||||||
throw std::bad_alloc();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Element>
|
|
||||||
OpenHashElementArray<Element>::~OpenHashElementArray()
|
|
||||||
{
|
|
||||||
free(fData);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Element>
|
|
||||||
Element &
|
|
||||||
OpenHashElementArray<Element>::At(int32 index)
|
|
||||||
{
|
|
||||||
ASSERT(index < fSize);
|
|
||||||
return fData[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Element>
|
|
||||||
const Element &
|
|
||||||
OpenHashElementArray<Element>::At(int32 index) const
|
|
||||||
{
|
|
||||||
ASSERT(index < fSize);
|
|
||||||
return fData[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Element>
|
|
||||||
int32
|
|
||||||
OpenHashElementArray<Element>::IndexOf(const Element &element) const
|
|
||||||
{
|
|
||||||
int32 result = &element - fData;
|
|
||||||
if (result < 0 || result > fSize)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Element>
|
|
||||||
int32
|
|
||||||
OpenHashElementArray<Element>::Size() const
|
|
||||||
{
|
|
||||||
return fSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Element>
|
|
||||||
int32
|
|
||||||
OpenHashElementArray<Element>::Add(const Element &newElement)
|
|
||||||
{
|
|
||||||
int32 index = Add();
|
|
||||||
At(index).Adopt(newElement);
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#if DEBUG
|
|
||||||
const int32 kGrowChunk = 10;
|
|
||||||
#else
|
|
||||||
const int32 kGrowChunk = 1024;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
template<class Element>
|
|
||||||
int32
|
|
||||||
OpenHashElementArray<Element>::Add()
|
|
||||||
{
|
|
||||||
int32 index = fNextFree;
|
|
||||||
if (fNextDeleted >= 0) {
|
|
||||||
index = fNextDeleted;
|
|
||||||
fNextDeleted = At(index).fNext;
|
|
||||||
} else if (fNextFree >= fSize - 1) {
|
|
||||||
int32 newSize = fSize + kGrowChunk;
|
|
||||||
Element *newData = (Element *)calloc((size_t)newSize , sizeof(Element));
|
|
||||||
if (!newData)
|
|
||||||
throw std::bad_alloc();
|
|
||||||
memcpy(newData, fData, fSize * sizeof(Element));
|
|
||||||
free(fData);
|
|
||||||
fData = newData;
|
|
||||||
fSize = newSize;
|
|
||||||
index = fNextFree;
|
|
||||||
fNextFree++;
|
|
||||||
} else
|
|
||||||
fNextFree++;
|
|
||||||
|
|
||||||
new (&At(index)) Element;
|
|
||||||
// call placement new to initialize the element properly
|
|
||||||
ASSERT(At(index).fNext == -1);
|
|
||||||
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Element>
|
|
||||||
void
|
|
||||||
OpenHashElementArray<Element>::Remove(int32 index)
|
|
||||||
{
|
|
||||||
// delete by chaining empty elements in a single linked
|
|
||||||
// list, reusing the next field
|
|
||||||
ASSERT(index < fSize);
|
|
||||||
At(index).~Element();
|
|
||||||
// call the destructor explicitly to destroy the element
|
|
||||||
// properly
|
|
||||||
At(index).fNext = fNextDeleted;
|
|
||||||
fNextDeleted = index;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace BPrivate
|
|
||||||
|
|
||||||
using namespace BPrivate;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -32,6 +32,7 @@ names are registered trademarks or trademarks of their respective holders.
|
|||||||
All rights reserved.
|
All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <Debug.h>
|
||||||
#include <InterfaceDefs.h>
|
#include <InterfaceDefs.h>
|
||||||
|
|
||||||
#include "AutoLock.h"
|
#include "AutoLock.h"
|
||||||
@@ -60,7 +61,7 @@ OneShotDelayedTask::~OneShotDelayedTask()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
OneShotDelayedTask::RunIfNeeded(bigtime_t currentTime)
|
OneShotDelayedTask::RunIfNeeded(bigtime_t currentTime)
|
||||||
{
|
{
|
||||||
if (currentTime < fRunAfter)
|
if (currentTime < fRunAfter)
|
||||||
@@ -86,7 +87,7 @@ PeriodicDelayedTask::~PeriodicDelayedTask()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
PeriodicDelayedTask::RunIfNeeded(bigtime_t currentTime)
|
PeriodicDelayedTask::RunIfNeeded(bigtime_t currentTime)
|
||||||
{
|
{
|
||||||
if (!currentTime < fRunAfter)
|
if (!currentTime < fRunAfter)
|
||||||
@@ -107,7 +108,7 @@ PeriodicDelayedTaskWithTimeout::PeriodicDelayedTaskWithTimeout(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
PeriodicDelayedTaskWithTimeout::RunIfNeeded(bigtime_t currentTime)
|
PeriodicDelayedTaskWithTimeout::RunIfNeeded(bigtime_t currentTime)
|
||||||
{
|
{
|
||||||
if (currentTime < fRunAfter)
|
if (currentTime < fRunAfter)
|
||||||
@@ -137,7 +138,7 @@ RunWhenIdleTask::~RunWhenIdleTask()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
RunWhenIdleTask::RunIfNeeded(bigtime_t currentTime)
|
RunWhenIdleTask::RunIfNeeded(bigtime_t currentTime)
|
||||||
{
|
{
|
||||||
if (currentTime < fRunAfter)
|
if (currentTime < fRunAfter)
|
||||||
@@ -146,7 +147,7 @@ RunWhenIdleTask::RunIfNeeded(bigtime_t currentTime)
|
|||||||
fRunAfter = currentTime + fPeriod;
|
fRunAfter = currentTime + fPeriod;
|
||||||
// PRINT(("runWhenIdle: runAfter %Ld, current time %Ld, period %Ld\n",
|
// PRINT(("runWhenIdle: runAfter %Ld, current time %Ld, period %Ld\n",
|
||||||
// fRunAfter, currentTime, fPeriod));
|
// fRunAfter, currentTime, fPeriod));
|
||||||
|
|
||||||
if (fState == kInitialDelay) {
|
if (fState == kInitialDelay) {
|
||||||
// PRINT(("run when idle task - past intial delay\n"));
|
// PRINT(("run when idle task - past intial delay\n"));
|
||||||
ResetIdleTimer(currentTime);
|
ResetIdleTimer(currentTime);
|
||||||
@@ -175,7 +176,7 @@ ActivityLevel()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
RunWhenIdleTask::ResetIdleTimer(bigtime_t currentTime)
|
RunWhenIdleTask::ResetIdleTimer(bigtime_t currentTime)
|
||||||
{
|
{
|
||||||
fActivityLevel = ActivityLevel();
|
fActivityLevel = ActivityLevel();
|
||||||
@@ -194,14 +195,14 @@ RunWhenIdleTask::IsIdle(bigtime_t currentTime, float taskOverhead)
|
|||||||
bigtime_t currentActivityLevel = ActivityLevel();
|
bigtime_t currentActivityLevel = ActivityLevel();
|
||||||
float load = (float)(currentActivityLevel - fActivityLevel)
|
float load = (float)(currentActivityLevel - fActivityLevel)
|
||||||
/ (float)(currentTime - fActivityLevelStart);
|
/ (float)(currentTime - fActivityLevelStart);
|
||||||
|
|
||||||
fActivityLevel = currentActivityLevel;
|
fActivityLevel = currentActivityLevel;
|
||||||
fActivityLevelStart = currentTime;
|
fActivityLevelStart = currentTime;
|
||||||
|
|
||||||
load -= taskOverhead;
|
load -= taskOverhead;
|
||||||
|
|
||||||
bool idle = true;
|
bool idle = true;
|
||||||
|
|
||||||
if (load > kIdleTreshold) {
|
if (load > kIdleTreshold) {
|
||||||
// PRINT(("not idle enough %f\n", load));
|
// PRINT(("not idle enough %f\n", load));
|
||||||
idle = false;
|
idle = false;
|
||||||
@@ -230,7 +231,7 @@ RunWhenIdleTask::IdleTimerExpired(bigtime_t currentTime)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
RunWhenIdleTask::StillIdle(bigtime_t currentTime)
|
RunWhenIdleTask::StillIdle(bigtime_t currentTime)
|
||||||
{
|
{
|
||||||
return IsIdle(currentTime, kIdleTreshold);
|
return IsIdle(currentTime, kIdleTreshold);
|
||||||
@@ -245,11 +246,11 @@ TaskLoop::TaskLoop(bigtime_t heartBeat)
|
|||||||
|
|
||||||
|
|
||||||
TaskLoop::~TaskLoop()
|
TaskLoop::~TaskLoop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TaskLoop::RunLater(DelayedTask *task)
|
TaskLoop::RunLater(DelayedTask *task)
|
||||||
{
|
{
|
||||||
AddTask(task);
|
AddTask(task);
|
||||||
@@ -263,7 +264,7 @@ TaskLoop::RunLater(FunctionObject *functor, bigtime_t delay)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TaskLoop::RunLater(FunctionObjectWithResult<bool> *functor,
|
TaskLoop::RunLater(FunctionObjectWithResult<bool> *functor,
|
||||||
bigtime_t delay, bigtime_t period)
|
bigtime_t delay, bigtime_t period)
|
||||||
{
|
{
|
||||||
@@ -271,7 +272,7 @@ TaskLoop::RunLater(FunctionObjectWithResult<bool> *functor,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TaskLoop::RunLater(FunctionObjectWithResult<bool> *functor, bigtime_t delay,
|
TaskLoop::RunLater(FunctionObjectWithResult<bool> *functor, bigtime_t delay,
|
||||||
bigtime_t period, bigtime_t timeout)
|
bigtime_t period, bigtime_t timeout)
|
||||||
{
|
{
|
||||||
@@ -279,7 +280,7 @@ TaskLoop::RunLater(FunctionObjectWithResult<bool> *functor, bigtime_t delay,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TaskLoop::RunWhenIdle(FunctionObjectWithResult<bool> *functor, bigtime_t initialDelay,
|
TaskLoop::RunWhenIdle(FunctionObjectWithResult<bool> *functor, bigtime_t initialDelay,
|
||||||
bigtime_t idleTime, bigtime_t heartBeat)
|
bigtime_t idleTime, bigtime_t heartBeat)
|
||||||
{
|
{
|
||||||
@@ -298,20 +299,20 @@ public:
|
|||||||
maxAccumulatingTime(maxAccumulatingTime),
|
maxAccumulatingTime(maxAccumulatingTime),
|
||||||
initialTime(system_time())
|
initialTime(system_time())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool CanAccumulate(const AccumulatingFunctionObject *accumulateThis) const
|
bool CanAccumulate(const AccumulatingFunctionObject *accumulateThis) const
|
||||||
{
|
{
|
||||||
if (maxAccumulateCount && accumulateCount > maxAccumulateCount)
|
if (maxAccumulateCount && accumulateCount > maxAccumulateCount)
|
||||||
// don't accumulate if too may accumulated already
|
// don't accumulate if too may accumulated already
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (maxAccumulatingTime && system_time() > initialTime + maxAccumulatingTime)
|
if (maxAccumulatingTime && system_time() > initialTime + maxAccumulatingTime)
|
||||||
// don't accumulate if too late past initial task
|
// don't accumulate if too late past initial task
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return static_cast<AccumulatingFunctionObject *>(fFunctor)->CanAccumulate(accumulateThis);
|
return static_cast<AccumulatingFunctionObject *>(fFunctor)->CanAccumulate(accumulateThis);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Accumulate(AccumulatingFunctionObject *accumulateThis, bigtime_t delay)
|
virtual void Accumulate(AccumulatingFunctionObject *accumulateThis, bigtime_t delay)
|
||||||
{
|
{
|
||||||
fRunAfter = system_time() + delay;
|
fRunAfter = system_time() + delay;
|
||||||
@@ -341,7 +342,7 @@ TaskLoop::AccumulatedRunLater(AccumulatingFunctionObject *functor, bigtime_t del
|
|||||||
(fTaskList.ItemAt(index));
|
(fTaskList.ItemAt(index));
|
||||||
if (!task)
|
if (!task)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (task->CanAccumulate(functor)) {
|
if (task->CanAccumulate(functor)) {
|
||||||
task->Accumulate(functor, delay);
|
task->Accumulate(functor, delay);
|
||||||
return;
|
return;
|
||||||
@@ -352,7 +353,7 @@ TaskLoop::AccumulatedRunLater(AccumulatingFunctionObject *functor, bigtime_t del
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
TaskLoop::Pulse()
|
TaskLoop::Pulse()
|
||||||
{
|
{
|
||||||
ASSERT(fLock.IsLocked());
|
ASSERT(fLock.IsLocked());
|
||||||
@@ -376,7 +377,7 @@ TaskLoop::Pulse()
|
|||||||
|
|
||||||
const bigtime_t kInfinity = B_INFINITE_TIMEOUT;
|
const bigtime_t kInfinity = B_INFINITE_TIMEOUT;
|
||||||
|
|
||||||
bigtime_t
|
bigtime_t
|
||||||
TaskLoop::LatestRunTime() const
|
TaskLoop::LatestRunTime() const
|
||||||
{
|
{
|
||||||
ASSERT(fLock.IsLocked());
|
ASSERT(fLock.IsLocked());
|
||||||
@@ -409,7 +410,7 @@ TaskLoop::LatestRunTime() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TaskLoop::RemoveTask(DelayedTask *task)
|
TaskLoop::RemoveTask(DelayedTask *task)
|
||||||
{
|
{
|
||||||
ASSERT(fLock.IsLocked());
|
ASSERT(fLock.IsLocked());
|
||||||
@@ -441,35 +442,35 @@ StandAloneTaskLoop::StandAloneTaskLoop(bool keepThread, bigtime_t heartBeat)
|
|||||||
|
|
||||||
|
|
||||||
StandAloneTaskLoop::~StandAloneTaskLoop()
|
StandAloneTaskLoop::~StandAloneTaskLoop()
|
||||||
{
|
{
|
||||||
fLock.Lock();
|
fLock.Lock();
|
||||||
fNeedToQuit = true;
|
fNeedToQuit = true;
|
||||||
bool easyOut = (fScanThread == -1);
|
bool easyOut = (fScanThread == -1);
|
||||||
fLock.Unlock();
|
fLock.Unlock();
|
||||||
|
|
||||||
if (!easyOut)
|
if (!easyOut)
|
||||||
for (int32 timeout = 10000; ; timeout--) {
|
for (int32 timeout = 10000; ; timeout--) {
|
||||||
// use a 10 sec timeout value in case the spawned
|
// use a 10 sec timeout value in case the spawned
|
||||||
// thread is stuck somewhere
|
// thread is stuck somewhere
|
||||||
|
|
||||||
if (!timeout) {
|
if (!timeout) {
|
||||||
PRINT(("StandAloneTaskLoop timed out, quitting abruptly"));
|
PRINT(("StandAloneTaskLoop timed out, quitting abruptly"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool done;
|
bool done;
|
||||||
|
|
||||||
fLock.Lock();
|
fLock.Lock();
|
||||||
done = (fScanThread == -1);
|
done = (fScanThread == -1);
|
||||||
fLock.Unlock();
|
fLock.Unlock();
|
||||||
if (done)
|
if (done)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
snooze(1000);
|
snooze(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
StandAloneTaskLoop::StartPulsingIfNeeded()
|
StandAloneTaskLoop::StartPulsingIfNeeded()
|
||||||
{
|
{
|
||||||
ASSERT(fLock.IsLocked());
|
ASSERT(fLock.IsLocked());
|
||||||
@@ -481,13 +482,13 @@ StandAloneTaskLoop::StartPulsingIfNeeded()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
StandAloneTaskLoop::KeepPulsingWhenEmpty() const
|
StandAloneTaskLoop::KeepPulsingWhenEmpty() const
|
||||||
{
|
{
|
||||||
return fKeepThread;
|
return fKeepThread;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
StandAloneTaskLoop::RunBinder(void *castToThis)
|
StandAloneTaskLoop::RunBinder(void *castToThis)
|
||||||
{
|
{
|
||||||
StandAloneTaskLoop *self = (StandAloneTaskLoop *)castToThis;
|
StandAloneTaskLoop *self = (StandAloneTaskLoop *)castToThis;
|
||||||
@@ -495,12 +496,12 @@ StandAloneTaskLoop::RunBinder(void *castToThis)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
StandAloneTaskLoop::Run()
|
StandAloneTaskLoop::Run()
|
||||||
{
|
{
|
||||||
for(;;) {
|
for(;;) {
|
||||||
AutoLock<BLocker> autoLock(&fLock);
|
AutoLock<BLocker> autoLock(&fLock);
|
||||||
if (!autoLock)
|
if (!autoLock)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (fNeedToQuit) {
|
if (fNeedToQuit) {
|
||||||
@@ -523,17 +524,17 @@ StandAloneTaskLoop::Run()
|
|||||||
bigtime_t afterHeartBeatTime = now + fHeartBeat;
|
bigtime_t afterHeartBeatTime = now + fHeartBeat;
|
||||||
bigtime_t snoozeTill = latestRunTime < afterHeartBeatTime ?
|
bigtime_t snoozeTill = latestRunTime < afterHeartBeatTime ?
|
||||||
latestRunTime : afterHeartBeatTime;
|
latestRunTime : afterHeartBeatTime;
|
||||||
|
|
||||||
autoLock.Unlock();
|
autoLock.Unlock();
|
||||||
|
|
||||||
if (snoozeTill > now)
|
if (snoozeTill > now)
|
||||||
snooze_until(snoozeTill, B_SYSTEM_TIMEBASE);
|
snooze_until(snoozeTill, B_SYSTEM_TIMEBASE);
|
||||||
else
|
else
|
||||||
snooze(1000);
|
snooze(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
StandAloneTaskLoop::AddTask(DelayedTask *delayedTask)
|
StandAloneTaskLoop::AddTask(DelayedTask *delayedTask)
|
||||||
{
|
{
|
||||||
_inherited::AddTask(delayedTask);
|
_inherited::AddTask(delayedTask);
|
||||||
@@ -544,9 +545,9 @@ StandAloneTaskLoop::AddTask(DelayedTask *delayedTask)
|
|||||||
thread_info info;
|
thread_info info;
|
||||||
get_thread_info(fScanThread, &info);
|
get_thread_info(fScanThread, &info);
|
||||||
if (info.state == B_THREAD_ASLEEP) {
|
if (info.state == B_THREAD_ASLEEP) {
|
||||||
suspend_thread(fScanThread);
|
suspend_thread(fScanThread);
|
||||||
snooze(1000); // snooze because BeBook sez so
|
snooze(1000); // snooze because BeBook sez so
|
||||||
resume_thread(fScanThread);
|
resume_thread(fScanThread);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -562,7 +563,7 @@ PiggybackTaskLoop::~PiggybackTaskLoop()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PiggybackTaskLoop::PulseMe()
|
PiggybackTaskLoop::PulseMe()
|
||||||
{
|
{
|
||||||
if (!fPulseMe)
|
if (!fPulseMe)
|
||||||
@@ -577,13 +578,13 @@ PiggybackTaskLoop::PulseMe()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
PiggybackTaskLoop::KeepPulsingWhenEmpty() const
|
PiggybackTaskLoop::KeepPulsingWhenEmpty() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PiggybackTaskLoop::StartPulsingIfNeeded()
|
PiggybackTaskLoop::StartPulsingIfNeeded()
|
||||||
{
|
{
|
||||||
fPulseMe = true;
|
fPulseMe = true;
|
||||||
|
|||||||
+24
-22
@@ -35,7 +35,9 @@ All rights reserved.
|
|||||||
#ifndef __THREAD__
|
#ifndef __THREAD__
|
||||||
#define __THREAD__
|
#define __THREAD__
|
||||||
|
|
||||||
|
#include <Debug.h>
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
|
|
||||||
#include "ObjectList.h"
|
#include "ObjectList.h"
|
||||||
#include "FunctionObject.h"
|
#include "FunctionObject.h"
|
||||||
#include "Utilities.h"
|
#include "Utilities.h"
|
||||||
@@ -48,7 +50,7 @@ class SimpleThread {
|
|||||||
public:
|
public:
|
||||||
SimpleThread(int32 priority = B_LOW_PRIORITY, const char *name = 0);
|
SimpleThread(int32 priority = B_LOW_PRIORITY, const char *name = 0);
|
||||||
virtual ~SimpleThread();
|
virtual ~SimpleThread();
|
||||||
|
|
||||||
void Go();
|
void Go();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -99,8 +101,8 @@ public:
|
|||||||
fParam1(param1)
|
fParam1(param1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void operator()()
|
virtual void operator()()
|
||||||
{ (fFunction)(fParam1); }
|
{ (fFunction)(fParam1); }
|
||||||
|
|
||||||
@@ -119,8 +121,8 @@ public:
|
|||||||
fOnThis(onThis)
|
fOnThis(onThis)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void operator()()
|
virtual void operator()()
|
||||||
{ (fOnThis->*fFunction)(); }
|
{ (fOnThis->*fFunction)(); }
|
||||||
|
|
||||||
@@ -141,7 +143,7 @@ public:
|
|||||||
fParam2(param2)
|
fParam2(param2)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void operator()()
|
virtual void operator()()
|
||||||
{ (function)(fParam1, fParam2); }
|
{ (function)(fParam1, fParam2); }
|
||||||
|
|
||||||
@@ -164,7 +166,7 @@ public:
|
|||||||
fParam3(param3)
|
fParam3(param3)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void operator()()
|
virtual void operator()()
|
||||||
{ (function)(fParam1, fParam2, fParam3); }
|
{ (function)(fParam1, fParam2, fParam3); }
|
||||||
|
|
||||||
@@ -189,7 +191,7 @@ public:
|
|||||||
fParam4(param4)
|
fParam4(param4)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void operator()()
|
virtual void operator()()
|
||||||
{ (function)(fParam1, fParam2, fParam3, fParam4); }
|
{ (function)(fParam1, fParam2, fParam3, fParam4); }
|
||||||
|
|
||||||
@@ -204,7 +206,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
template<class Param1>
|
template<class Param1>
|
||||||
void
|
void
|
||||||
LaunchInNewThread(const char *name, int32 priority, status_t (*func)(Param1), Param1 p1)
|
LaunchInNewThread(const char *name, int32 priority, status_t (*func)(Param1), Param1 p1)
|
||||||
{
|
{
|
||||||
Thread::Launch(new SingleParamFunctionObjectWorkaround<Param1>(func, p1),
|
Thread::Launch(new SingleParamFunctionObjectWorkaround<Param1>(func, p1),
|
||||||
@@ -212,7 +214,7 @@ LaunchInNewThread(const char *name, int32 priority, status_t (*func)(Param1), Pa
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void
|
void
|
||||||
LaunchInNewThread(const char *name, int32 priority, status_t (T::*function)(), T *onThis)
|
LaunchInNewThread(const char *name, int32 priority, status_t (T::*function)(), T *onThis)
|
||||||
{
|
{
|
||||||
Thread::Launch(new SimpleMemberFunctionObjectWorkaround<T>(function, onThis),
|
Thread::Launch(new SimpleMemberFunctionObjectWorkaround<T>(function, onThis),
|
||||||
@@ -220,7 +222,7 @@ LaunchInNewThread(const char *name, int32 priority, status_t (T::*function)(), T
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class Param1, class Param2>
|
template<class Param1, class Param2>
|
||||||
void
|
void
|
||||||
LaunchInNewThread(const char *name, int32 priority,
|
LaunchInNewThread(const char *name, int32 priority,
|
||||||
status_t (*func)(Param1, Param2),
|
status_t (*func)(Param1, Param2),
|
||||||
Param1 p1, Param2 p2)
|
Param1 p1, Param2 p2)
|
||||||
@@ -230,7 +232,7 @@ LaunchInNewThread(const char *name, int32 priority,
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class Param1, class Param2, class Param3>
|
template<class Param1, class Param2, class Param3>
|
||||||
void
|
void
|
||||||
LaunchInNewThread(const char *name, int32 priority,
|
LaunchInNewThread(const char *name, int32 priority,
|
||||||
status_t (*func)(Param1, Param2, Param3),
|
status_t (*func)(Param1, Param2, Param3),
|
||||||
Param1 p1, Param2 p2, Param3 p3)
|
Param1 p1, Param2 p2, Param3 p3)
|
||||||
@@ -240,7 +242,7 @@ LaunchInNewThread(const char *name, int32 priority,
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class Param1, class Param2, class Param3, class Param4>
|
template<class Param1, class Param2, class Param3, class Param4>
|
||||||
void
|
void
|
||||||
LaunchInNewThread(const char *name, int32 priority,
|
LaunchInNewThread(const char *name, int32 priority,
|
||||||
status_t (*func)(Param1, Param2, Param3, Param4),
|
status_t (*func)(Param1, Param2, Param3, Param4),
|
||||||
Param1 p1, Param2 p2, Param3 p3, Param4 p4)
|
Param1 p1, Param2 p2, Param3 p3, Param4 p4)
|
||||||
@@ -260,13 +262,13 @@ protected:
|
|||||||
void (View::*)(BPoint, uint32), bigtime_t pressingPeriod);
|
void (View::*)(BPoint, uint32), bigtime_t pressingPeriod);
|
||||||
|
|
||||||
virtual ~MouseDownThread();
|
virtual ~MouseDownThread();
|
||||||
|
|
||||||
void Go();
|
void Go();
|
||||||
virtual void Track();
|
virtual void Track();
|
||||||
|
|
||||||
static status_t TrackBinder(void *);
|
static status_t TrackBinder(void *);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
BMessenger fOwner;
|
BMessenger fOwner;
|
||||||
void (View::*fDonePressing)(BPoint);
|
void (View::*fDonePressing)(BPoint);
|
||||||
void (View::*fPressing)(BPoint, uint32);
|
void (View::*fPressing)(BPoint, uint32);
|
||||||
@@ -309,19 +311,19 @@ MouseDownThread<View>::~MouseDownThread()
|
|||||||
|
|
||||||
|
|
||||||
template<class View>
|
template<class View>
|
||||||
void
|
void
|
||||||
MouseDownThread<View>::Go()
|
MouseDownThread<View>::Go()
|
||||||
{
|
{
|
||||||
fThreadID = spawn_thread(&MouseDownThread::TrackBinder, "MouseTrackingThread",
|
fThreadID = spawn_thread(&MouseDownThread::TrackBinder, "MouseTrackingThread",
|
||||||
B_NORMAL_PRIORITY, this);
|
B_NORMAL_PRIORITY, this);
|
||||||
|
|
||||||
if (fThreadID <= 0 || resume_thread(fThreadID) != B_OK)
|
if (fThreadID <= 0 || resume_thread(fThreadID) != B_OK)
|
||||||
// didn't start, don't leak self
|
// didn't start, don't leak self
|
||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class View>
|
template<class View>
|
||||||
status_t
|
status_t
|
||||||
MouseDownThread<View>::TrackBinder(void *castToThis)
|
MouseDownThread<View>::TrackBinder(void *castToThis)
|
||||||
{
|
{
|
||||||
MouseDownThread *self = static_cast<MouseDownThread *>(castToThis);
|
MouseDownThread *self = static_cast<MouseDownThread *>(castToThis);
|
||||||
@@ -332,7 +334,7 @@ MouseDownThread<View>::TrackBinder(void *castToThis)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class View>
|
template<class View>
|
||||||
void
|
void
|
||||||
MouseDownThread<View>::Track()
|
MouseDownThread<View>::Track()
|
||||||
{
|
{
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@@ -354,11 +356,11 @@ MouseDownThread<View>::Track()
|
|||||||
}
|
}
|
||||||
if (fPressing)
|
if (fPressing)
|
||||||
(view->*fPressing)(location, buttons);
|
(view->*fPressing)(location, buttons);
|
||||||
|
|
||||||
lock.Unlock();
|
lock.Unlock();
|
||||||
snooze(fPressingPeriod);
|
snooze(fPressingPeriod);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete this;
|
delete this;
|
||||||
ASSERT(!"should not be here");
|
ASSERT(!"should not be here");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,9 +32,11 @@ names are registered trademarks or trademarks of their respective holders.
|
|||||||
All rights reserved.
|
All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "TrackerSettings.h"
|
||||||
|
|
||||||
|
#include <Debug.h>
|
||||||
|
|
||||||
#include "Tracker.h"
|
#include "Tracker.h"
|
||||||
#include "TrackerSettings.h"
|
|
||||||
#include "WidgetAttributeText.h"
|
#include "WidgetAttributeText.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -107,7 +109,7 @@ rgb_color ValueToColor(int32 value)
|
|||||||
color.green = static_cast<uchar>((value >> 8L) & 0xff);
|
color.green = static_cast<uchar>((value >> 8L) & 0xff);
|
||||||
color.blue = static_cast<uchar>(value & 0xff);
|
color.blue = static_cast<uchar>(value & 0xff);
|
||||||
|
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -146,7 +148,7 @@ TTrackerState::~TTrackerState()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TTrackerState::SaveSettings(bool onlyIfNonDefault)
|
TTrackerState::SaveSettings(bool onlyIfNonDefault)
|
||||||
{
|
{
|
||||||
if (fSettingsLoaded)
|
if (fSettingsLoaded)
|
||||||
@@ -154,7 +156,7 @@ TTrackerState::SaveSettings(bool onlyIfNonDefault)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TTrackerState::LoadSettingsIfNeeded()
|
TTrackerState::LoadSettingsIfNeeded()
|
||||||
{
|
{
|
||||||
if (fSettingsLoaded)
|
if (fSettingsLoaded)
|
||||||
@@ -215,7 +217,7 @@ TrackerSettings::TrackerSettings()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TrackerSettings::SaveSettings(bool onlyIfNonDefault)
|
TrackerSettings::SaveSettings(bool onlyIfNonDefault)
|
||||||
{
|
{
|
||||||
gTrackerState.SaveSettings(onlyIfNonDefault);
|
gTrackerState.SaveSettings(onlyIfNonDefault);
|
||||||
@@ -243,7 +245,7 @@ TrackerSettings::DesktopFilePanelRoot()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TrackerSettings::SetDesktopFilePanelRoot(bool enabled)
|
TrackerSettings::SetDesktopFilePanelRoot(bool enabled)
|
||||||
{
|
{
|
||||||
gTrackerState.fDesktopFilePanelRoot->SetValue(enabled);
|
gTrackerState.fDesktopFilePanelRoot->SetValue(enabled);
|
||||||
@@ -257,7 +259,7 @@ TrackerSettings::MountVolumesOntoDesktop()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TrackerSettings::SetMountVolumesOntoDesktop(bool enabled)
|
TrackerSettings::SetMountVolumesOntoDesktop(bool enabled)
|
||||||
{
|
{
|
||||||
gTrackerState.fMountVolumesOntoDesktop->SetValue(enabled);
|
gTrackerState.fMountVolumesOntoDesktop->SetValue(enabled);
|
||||||
@@ -271,7 +273,7 @@ TrackerSettings::MountSharedVolumesOntoDesktop()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TrackerSettings::SetMountSharedVolumesOntoDesktop(bool enabled)
|
TrackerSettings::SetMountSharedVolumesOntoDesktop(bool enabled)
|
||||||
{
|
{
|
||||||
gTrackerState.fMountSharedVolumesOntoDesktop->SetValue(enabled);
|
gTrackerState.fMountSharedVolumesOntoDesktop->SetValue(enabled);
|
||||||
@@ -285,7 +287,7 @@ TrackerSettings::IntegrateNonBootBeOSDesktops()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TrackerSettings::SetIntegrateNonBootBeOSDesktops(bool enabled)
|
TrackerSettings::SetIntegrateNonBootBeOSDesktops(bool enabled)
|
||||||
{
|
{
|
||||||
gTrackerState.fIntegrateNonBootBeOSDesktops->SetValue(enabled);
|
gTrackerState.fIntegrateNonBootBeOSDesktops->SetValue(enabled);
|
||||||
@@ -305,7 +307,7 @@ TrackerSettings::EjectWhenUnmounting()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TrackerSettings::SetEjectWhenUnmounting(bool enabled)
|
TrackerSettings::SetEjectWhenUnmounting(bool enabled)
|
||||||
{
|
{
|
||||||
gTrackerState.fEjectWhenUnmounting->SetValue(enabled);
|
gTrackerState.fEjectWhenUnmounting->SetValue(enabled);
|
||||||
@@ -397,14 +399,14 @@ TrackerSettings::SetSortFolderNamesFirst(bool enabled)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
TrackerSettings::HideDotFiles()
|
TrackerSettings::HideDotFiles()
|
||||||
{
|
{
|
||||||
return gTrackerState.fHideDotFiles->Value();
|
return gTrackerState.fHideDotFiles->Value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TrackerSettings::SetHideDotFiles(bool hide)
|
TrackerSettings::SetHideDotFiles(bool hide)
|
||||||
{
|
{
|
||||||
gTrackerState.fHideDotFiles->SetValue(hide);
|
gTrackerState.fHideDotFiles->SetValue(hide);
|
||||||
@@ -479,21 +481,21 @@ TrackerSettings::RecentCounts(int32 *applications, int32 *documents, int32 *fold
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TrackerSettings::SetRecentApplicationsCount(int32 count)
|
TrackerSettings::SetRecentApplicationsCount(int32 count)
|
||||||
{
|
{
|
||||||
gTrackerState.fRecentApplicationsCount->ValueChanged(count);
|
gTrackerState.fRecentApplicationsCount->ValueChanged(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TrackerSettings::SetRecentDocumentsCount(int32 count)
|
TrackerSettings::SetRecentDocumentsCount(int32 count)
|
||||||
{
|
{
|
||||||
gTrackerState.fRecentDocumentsCount->ValueChanged(count);
|
gTrackerState.fRecentDocumentsCount->ValueChanged(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TrackerSettings::SetRecentFoldersCount(int32 count)
|
TrackerSettings::SetRecentFoldersCount(int32 count)
|
||||||
{
|
{
|
||||||
gTrackerState.fRecentFoldersCount->ValueChanged(count);
|
gTrackerState.fRecentFoldersCount->ValueChanged(count);
|
||||||
|
|||||||
@@ -35,6 +35,9 @@ All rights reserved.
|
|||||||
#ifndef _UTILITIES_H
|
#ifndef _UTILITIES_H
|
||||||
#define _UTILITIES_H
|
#define _UTILITIES_H
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <ByteOrder.h>
|
#include <ByteOrder.h>
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
#include <DataIO.h>
|
#include <DataIO.h>
|
||||||
@@ -52,7 +55,6 @@ All rights reserved.
|
|||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <StringView.h>
|
#include <StringView.h>
|
||||||
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
class BMessage;
|
class BMessage;
|
||||||
class BVolume;
|
class BVolume;
|
||||||
@@ -133,7 +135,7 @@ class PoseInfo {
|
|||||||
// them in the same location. This should probably be reworked -- Tracker
|
// them in the same location. This should probably be reworked -- Tracker
|
||||||
// could say strip the file location attributes when dropping files into
|
// could say strip the file location attributes when dropping files into
|
||||||
// a closed folder
|
// a closed folder
|
||||||
BPoint fLocation;
|
BPoint fLocation;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -165,7 +167,7 @@ class ExtendedPoseInfo {
|
|||||||
|
|
||||||
int32 fNumFrames;
|
int32 fNumFrames;
|
||||||
struct FrameLocation {
|
struct FrameLocation {
|
||||||
BPoint fLocation;
|
BPoint fLocation;
|
||||||
BRect fFrame;
|
BRect fFrame;
|
||||||
uint32 fWorkspaces;
|
uint32 fWorkspaces;
|
||||||
};
|
};
|
||||||
@@ -178,19 +180,19 @@ void DisallowMetaKeys(BTextView *);
|
|||||||
void DisallowFilenameKeys(BTextView *);
|
void DisallowFilenameKeys(BTextView *);
|
||||||
|
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
IsDigit(const char c)
|
IsDigit(const char c)
|
||||||
{
|
{
|
||||||
if ((c >= 48 && c <= 57) || c == 32)
|
if ((c >= 48 && c <= 57) || c == 32)
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Compares two strings naturally, as opposed to lexicographically
|
//! Compares two strings naturally, as opposed to lexicographically
|
||||||
inline int
|
inline int
|
||||||
NaturalCompare(const char *s1, const char *s2)
|
NaturalCompare(const char *s1, const char *s2)
|
||||||
{
|
{
|
||||||
struct Chunk {
|
struct Chunk {
|
||||||
int32 type;
|
int32 type;
|
||||||
@@ -214,18 +216,18 @@ NaturalCompare(const char *s1, const char *s2)
|
|||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
// determine type of next chunks in each string based on first char
|
// determine type of next chunks in each string based on first char
|
||||||
if (i == len1)
|
if (i == len1)
|
||||||
a.type = -1;
|
a.type = -1;
|
||||||
else if (IsDigit(s1[i]))
|
else if (IsDigit(s1[i]))
|
||||||
a.type = 1;
|
a.type = 1;
|
||||||
else
|
else
|
||||||
a.type = 0;
|
a.type = 0;
|
||||||
|
|
||||||
if (j == len2)
|
if (j == len2)
|
||||||
b.type = -1;
|
b.type = -1;
|
||||||
else if (IsDigit(s2[j]))
|
else if (IsDigit(s2[j]))
|
||||||
b.type = 1;
|
b.type = 1;
|
||||||
else
|
else
|
||||||
b.type = 0;
|
b.type = 0;
|
||||||
|
|
||||||
// check if we reached the end of either string
|
// check if we reached the end of either string
|
||||||
@@ -346,12 +348,12 @@ extern void FadeRGBA32Vertical(uint32 *bits, int32 width, int32 height, int32 fr
|
|||||||
|
|
||||||
class FlickerFreeStringView : public BStringView {
|
class FlickerFreeStringView : public BStringView {
|
||||||
// Adds support for offscreen bitmap drawing for string views that update often
|
// Adds support for offscreen bitmap drawing for string views that update often
|
||||||
// this would be better implemented as an option of BStringView
|
// this would be better implemented as an option of BStringView
|
||||||
public:
|
public:
|
||||||
FlickerFreeStringView(BRect bounds, const char *name,
|
FlickerFreeStringView(BRect bounds, const char *name,
|
||||||
const char *text, uint32 resizeFlags = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
const char *text, uint32 resizeFlags = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||||
uint32 flags = B_WILL_DRAW);
|
uint32 flags = B_WILL_DRAW);
|
||||||
FlickerFreeStringView(BRect bounds, const char *name,
|
FlickerFreeStringView(BRect bounds, const char *name,
|
||||||
const char *text, BBitmap *existingOffscreen,
|
const char *text, BBitmap *existingOffscreen,
|
||||||
uint32 resizeFlags = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
uint32 resizeFlags = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||||
uint32 flags = B_WILL_DRAW);
|
uint32 flags = B_WILL_DRAW);
|
||||||
@@ -407,7 +409,7 @@ class PositionPassingMenuItem : public BMenuItem {
|
|||||||
protected:
|
protected:
|
||||||
virtual status_t Invoke(BMessage * = 0);
|
virtual status_t Invoke(BMessage * = 0);
|
||||||
// appends the invoke location for NewFolder, etc. to use
|
// appends the invoke location for NewFolder, etc. to use
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef BMenuItem _inherited;
|
typedef BMenuItem _inherited;
|
||||||
};
|
};
|
||||||
@@ -707,14 +709,14 @@ inline void PrintDirToStream(const BDirectory *, const char * = 0) {}
|
|||||||
|
|
||||||
#ifdef xDEBUG
|
#ifdef xDEBUG
|
||||||
|
|
||||||
extern FILE *logFile;
|
extern FILE *logFile;
|
||||||
|
|
||||||
inline void PrintToLogFile(const char *fmt, ...)
|
inline void PrintToLogFile(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
vfprintf(logFile, fmt, ap);
|
vfprintf(logFile, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define WRITELOG(_ARGS_) \
|
#define WRITELOG(_ARGS_) \
|
||||||
@@ -729,7 +731,7 @@ inline void PrintDirToStream(const BDirectory *, const char * = 0) {}
|
|||||||
PrintToLogFile("\n"); \
|
PrintToLogFile("\n"); \
|
||||||
fflush(logFile); \
|
fflush(logFile); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define WRITELOG(_ARGS_)
|
#define WRITELOG(_ARGS_)
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ All rights reserved.
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
|
#include <Debug.h>
|
||||||
#include <Node.h>
|
#include <Node.h>
|
||||||
#include <TranslationKit.h>
|
#include <TranslationKit.h>
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <Debug.h>
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
#include <MenuField.h>
|
#include <MenuField.h>
|
||||||
#include <StorageKit.h>
|
#include <StorageKit.h>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include <NetEndpoint.h>
|
#include <NetEndpoint.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
// #define DEBUG 1
|
// #define DEBUG 1
|
||||||
|
|
||||||
@@ -64,7 +65,7 @@ BRawNetBuffer::AppendString(const char* string)
|
|||||||
status_t
|
status_t
|
||||||
BRawNetBuffer::ReadUint16(uint16& value)
|
BRawNetBuffer::ReadUint16(uint16& value)
|
||||||
{
|
{
|
||||||
uint16 netVal;
|
uint16 netVal;
|
||||||
ssize_t sizeW = fBuffer.ReadAt(fReadPosition, &netVal, sizeof(uint16));
|
ssize_t sizeW = fBuffer.ReadAt(fReadPosition, &netVal, sizeof(uint16));
|
||||||
if (sizeW == 0)
|
if (sizeW == 0)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
@@ -77,7 +78,7 @@ BRawNetBuffer::ReadUint16(uint16& value)
|
|||||||
status_t
|
status_t
|
||||||
BRawNetBuffer::ReadUint32(uint32& value)
|
BRawNetBuffer::ReadUint32(uint32& value)
|
||||||
{
|
{
|
||||||
uint32 netVal;
|
uint32 netVal;
|
||||||
ssize_t sizeW = fBuffer.ReadAt(fReadPosition, &netVal, sizeof(uint32));
|
ssize_t sizeW = fBuffer.ReadAt(fReadPosition, &netVal, sizeof(uint32));
|
||||||
if (sizeW == 0)
|
if (sizeW == 0)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
@@ -92,7 +93,7 @@ BRawNetBuffer::ReadString(BString& string)
|
|||||||
{
|
{
|
||||||
char* buffer = (char*)fBuffer.Buffer();
|
char* buffer = (char*)fBuffer.Buffer();
|
||||||
buffer = &buffer[fReadPosition];
|
buffer = &buffer[fReadPosition];
|
||||||
|
|
||||||
// if the string is compressed we have to follow the links to the
|
// if the string is compressed we have to follow the links to the
|
||||||
// sub strings
|
// sub strings
|
||||||
while (*buffer != 0) {
|
while (*buffer != 0) {
|
||||||
@@ -209,7 +210,7 @@ DNSTools::ConvertToDNSName(const BString& string)
|
|||||||
dot = outString.FindFirst(".", lastDot + 1);
|
dot = outString.FindFirst(".", lastDot + 1);
|
||||||
if (dot == B_ERROR)
|
if (dot == B_ERROR)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// set a counts to the dot
|
// set a counts to the dot
|
||||||
diff = dot - 1 - lastDot;
|
diff = dot - 1 - lastDot;
|
||||||
outString[lastDot] = (char)diff;
|
outString[lastDot] = (char)diff;
|
||||||
@@ -286,13 +287,13 @@ DNSQuery::GetMXRecords(BString serverName, BObjectList<mx_record>* mxList,
|
|||||||
in_addr dnsAddress;
|
in_addr dnsAddress;
|
||||||
if (ReadDNSServer(&dnsAddress) != B_OK)
|
if (ReadDNSServer(&dnsAddress) != B_OK)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
// create dns query package
|
// create dns query package
|
||||||
BRawNetBuffer buffer;
|
BRawNetBuffer buffer;
|
||||||
dns_header header;
|
dns_header header;
|
||||||
_SetMXHeader(&header);
|
_SetMXHeader(&header);
|
||||||
_AppendQueryHeader(buffer, &header);
|
_AppendQueryHeader(buffer, &header);
|
||||||
|
|
||||||
BString serverNameConv = DNSTools::ConvertToDNSName(serverName);
|
BString serverNameConv = DNSTools::ConvertToDNSName(serverName);
|
||||||
buffer.AppendString(serverNameConv.String());
|
buffer.AppendString(serverNameConv.String());
|
||||||
buffer.AppendUint16(uint16(MX_RECORD));
|
buffer.AppendUint16(uint16(MX_RECORD));
|
||||||
@@ -308,7 +309,7 @@ DNSQuery::GetMXRecords(BString serverName, BObjectList<mx_record>* mxList,
|
|||||||
if (netEndpoint.Connect(netAddress) != B_OK)
|
if (netEndpoint.Connect(netAddress) != B_OK)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
PRINT("Connected\n");
|
PRINT("Connected\n");
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
int32 bytesSend =
|
int32 bytesSend =
|
||||||
#endif
|
#endif
|
||||||
@@ -319,12 +320,12 @@ DNSQuery::GetMXRecords(BString serverName, BObjectList<mx_record>* mxList,
|
|||||||
BRawNetBuffer receiBuffer(512);
|
BRawNetBuffer receiBuffer(512);
|
||||||
netEndpoint.SetTimeout(timeout);
|
netEndpoint.SetTimeout(timeout);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
int32 bytesRecei =
|
int32 bytesRecei =
|
||||||
#endif
|
#endif
|
||||||
netEndpoint.ReceiveFrom(receiBuffer.Data(), 512, netAddress);
|
netEndpoint.ReceiveFrom(receiBuffer.Data(), 512, netAddress);
|
||||||
PRINT("bytes received %i\n", int(bytesRecei));
|
PRINT("bytes received %i\n", int(bytesRecei));
|
||||||
dns_header receiHeader;
|
dns_header receiHeader;
|
||||||
|
|
||||||
_ReadQueryHeader(receiBuffer, &receiHeader);
|
_ReadQueryHeader(receiBuffer, &receiHeader);
|
||||||
PRINT("Package contains :");
|
PRINT("Package contains :");
|
||||||
PRINT("%d Questions, ", receiHeader.q_count);
|
PRINT("%d Questions, ", receiHeader.q_count);
|
||||||
@@ -338,7 +339,7 @@ DNSQuery::GetMXRecords(BString serverName, BObjectList<mx_record>* mxList,
|
|||||||
receiBuffer.ReadString(dummyS);
|
receiBuffer.ReadString(dummyS);
|
||||||
receiBuffer.ReadUint16(dummy);
|
receiBuffer.ReadUint16(dummy);
|
||||||
receiBuffer.ReadUint16(dummy);
|
receiBuffer.ReadUint16(dummy);
|
||||||
|
|
||||||
bool mxRecordFound = false;
|
bool mxRecordFound = false;
|
||||||
for (int i = 0; i < receiHeader.ans_count; i++) {
|
for (int i = 0; i < receiHeader.ans_count; i++) {
|
||||||
resource_record_head rrHead;
|
resource_record_head rrHead;
|
||||||
@@ -356,7 +357,7 @@ DNSQuery::GetMXRecords(BString serverName, BObjectList<mx_record>* mxList,
|
|||||||
buffer.SkipReading(rrHead.dataLength);
|
buffer.SkipReading(rrHead.dataLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mxRecordFound)
|
if (!mxRecordFound)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
#include "pr_server.h"
|
#include "pr_server.h"
|
||||||
#include "SpoolFolder.h"
|
#include "SpoolFolder.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
#include <WindowInfo.h>
|
#include <WindowInfo.h>
|
||||||
#include <ServerProtocol.h>
|
#include <ServerProtocol.h>
|
||||||
|
|
||||||
|
#include <Debug.h>
|
||||||
#include <DirectWindow.h>
|
#include <DirectWindow.h>
|
||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
|
|||||||
@@ -48,6 +48,7 @@
|
|||||||
|
|
||||||
#include <AppDefs.h>
|
#include <AppDefs.h>
|
||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
|
#include <Debug.h>
|
||||||
#include <List.h>
|
#include <List.h>
|
||||||
#include <ScrollBar.h>
|
#include <ScrollBar.h>
|
||||||
#include <Shape.h>
|
#include <Shape.h>
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include <ShapePrivate.h>
|
#include <ShapePrivate.h>
|
||||||
|
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
|
#include <Debug.h>
|
||||||
#include <List.h>
|
#include <List.h>
|
||||||
#include <Shape.h>
|
#include <Shape.h>
|
||||||
|
|
||||||
@@ -91,7 +92,7 @@ ShapePainter::IterateLineTo(int32 lineCount, BPoint *linePts)
|
|||||||
fOpStack.push(OP_LINETO | lineCount);
|
fOpStack.push(OP_LINETO | lineCount);
|
||||||
for (int32 i = 0; i < lineCount; i++)
|
for (int32 i = 0; i < lineCount; i++)
|
||||||
fPtStack.push(linePts[i]);
|
fPtStack.push(linePts[i]);
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +113,7 @@ status_t
|
|||||||
ShapePainter::IterateClose(void)
|
ShapePainter::IterateClose(void)
|
||||||
{
|
{
|
||||||
fOpStack.push(OP_CLOSE);
|
fOpStack.push(OP_CLOSE);
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,8 +129,8 @@ ShapePainter::Draw(View *view, BRect frame, bool filled)
|
|||||||
int32 i;
|
int32 i;
|
||||||
uint32 *opList = new (std::nothrow) uint32[opCount];
|
uint32 *opList = new (std::nothrow) uint32[opCount];
|
||||||
if (opList == NULL)
|
if (opList == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BPoint *ptList = new (std::nothrow) BPoint[ptCount];
|
BPoint *ptList = new (std::nothrow) BPoint[ptCount];
|
||||||
if (ptList == NULL) {
|
if (ptList == NULL) {
|
||||||
delete[] opList;
|
delete[] opList;
|
||||||
@@ -163,7 +164,7 @@ get_polygon_frame(const BPoint *points, int32 numPoints, BRect *_frame)
|
|||||||
float l, t, r, b;
|
float l, t, r, b;
|
||||||
|
|
||||||
ASSERT(numPoints > 0);
|
ASSERT(numPoints > 0);
|
||||||
|
|
||||||
l = r = points->x;
|
l = r = points->x;
|
||||||
t = b = points->y;
|
t = b = points->y;
|
||||||
|
|
||||||
@@ -205,7 +206,7 @@ stroke_line(View *view, BPoint start, BPoint end)
|
|||||||
BPoint penPos = end;
|
BPoint penPos = end;
|
||||||
|
|
||||||
view->ConvertToScreenForDrawing(&start);
|
view->ConvertToScreenForDrawing(&start);
|
||||||
view->ConvertToScreenForDrawing(&end);
|
view->ConvertToScreenForDrawing(&end);
|
||||||
view->Window()->GetDrawingEngine()->StrokeLine(start, end);
|
view->Window()->GetDrawingEngine()->StrokeLine(start, end);
|
||||||
|
|
||||||
view->CurrentState()->SetPenLocation(penPos);
|
view->CurrentState()->SetPenLocation(penPos);
|
||||||
@@ -218,7 +219,7 @@ stroke_line(View *view, BPoint start, BPoint end)
|
|||||||
static void
|
static void
|
||||||
stroke_rect(View *view, BRect rect)
|
stroke_rect(View *view, BRect rect)
|
||||||
{
|
{
|
||||||
view->ConvertToScreenForDrawing(&rect);
|
view->ConvertToScreenForDrawing(&rect);
|
||||||
view->Window()->GetDrawingEngine()->StrokeRect(rect);
|
view->Window()->GetDrawingEngine()->StrokeRect(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,7 +227,7 @@ stroke_rect(View *view, BRect rect)
|
|||||||
static void
|
static void
|
||||||
fill_rect(View *view, BRect rect)
|
fill_rect(View *view, BRect rect)
|
||||||
{
|
{
|
||||||
view->ConvertToScreenForDrawing(&rect);
|
view->ConvertToScreenForDrawing(&rect);
|
||||||
view->Window()->GetDrawingEngine()->FillRect(rect);
|
view->Window()->GetDrawingEngine()->FillRect(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,7 +235,7 @@ fill_rect(View *view, BRect rect)
|
|||||||
static void
|
static void
|
||||||
stroke_round_rect(View *view, BRect rect, BPoint radii)
|
stroke_round_rect(View *view, BRect rect, BPoint radii)
|
||||||
{
|
{
|
||||||
view->ConvertToScreenForDrawing(&rect);
|
view->ConvertToScreenForDrawing(&rect);
|
||||||
view->Window()->GetDrawingEngine()->DrawRoundRect(rect, radii.x, radii.y,
|
view->Window()->GetDrawingEngine()->DrawRoundRect(rect, radii.x, radii.y,
|
||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
@@ -243,7 +244,7 @@ stroke_round_rect(View *view, BRect rect, BPoint radii)
|
|||||||
static void
|
static void
|
||||||
fill_round_rect(View *view, BRect rect, BPoint radii)
|
fill_round_rect(View *view, BRect rect, BPoint radii)
|
||||||
{
|
{
|
||||||
view->ConvertToScreenForDrawing(&rect);
|
view->ConvertToScreenForDrawing(&rect);
|
||||||
view->Window()->GetDrawingEngine()->DrawRoundRect(rect, radii.x, radii.y,
|
view->Window()->GetDrawingEngine()->DrawRoundRect(rect, radii.x, radii.y,
|
||||||
true);
|
true);
|
||||||
}
|
}
|
||||||
@@ -341,7 +342,7 @@ stroke_polygon(View *view, int32 numPoints, const BPoint *viewPoints,
|
|||||||
BRect polyFrame;
|
BRect polyFrame;
|
||||||
get_polygon_frame(points, numPoints, &polyFrame);
|
get_polygon_frame(points, numPoints, &polyFrame);
|
||||||
|
|
||||||
view->Window()->GetDrawingEngine()->DrawPolygon(points, numPoints, polyFrame,
|
view->Window()->GetDrawingEngine()->DrawPolygon(points, numPoints, polyFrame,
|
||||||
false, isClosed && numPoints > 2);
|
false, isClosed && numPoints > 2);
|
||||||
free(points);
|
free(points);
|
||||||
}
|
}
|
||||||
@@ -364,11 +365,11 @@ fill_polygon(View *view, int32 numPoints, const BPoint *viewPoints)
|
|||||||
BRect polyFrame;
|
BRect polyFrame;
|
||||||
get_polygon_frame(points, numPoints, &polyFrame);
|
get_polygon_frame(points, numPoints, &polyFrame);
|
||||||
|
|
||||||
view->Window()->GetDrawingEngine()->DrawPolygon(points, numPoints, polyFrame,
|
view->Window()->GetDrawingEngine()->DrawPolygon(points, numPoints, polyFrame,
|
||||||
true, true);
|
true, true);
|
||||||
} else {
|
} else {
|
||||||
// avoid constructor/destructor calls by using malloc instead of new []
|
// avoid constructor/destructor calls by using malloc instead of new []
|
||||||
BPoint *points = (BPoint *)malloc(numPoints * sizeof(BPoint));
|
BPoint *points = (BPoint *)malloc(numPoints * sizeof(BPoint));
|
||||||
if (!points)
|
if (!points)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -377,7 +378,7 @@ fill_polygon(View *view, int32 numPoints, const BPoint *viewPoints)
|
|||||||
BRect polyFrame;
|
BRect polyFrame;
|
||||||
get_polygon_frame(points, numPoints, &polyFrame);
|
get_polygon_frame(points, numPoints, &polyFrame);
|
||||||
|
|
||||||
view->Window()->GetDrawingEngine()->DrawPolygon(points, numPoints, polyFrame,
|
view->Window()->GetDrawingEngine()->DrawPolygon(points, numPoints, polyFrame,
|
||||||
true, true);
|
true, true);
|
||||||
free(points);
|
free(points);
|
||||||
}
|
}
|
||||||
@@ -431,14 +432,14 @@ draw_pixels(View *view, BRect src, BRect dest, int32 width, int32 height,
|
|||||||
{
|
{
|
||||||
UtilityBitmap bitmap(BRect(0, 0, width - 1, height - 1),
|
UtilityBitmap bitmap(BRect(0, 0, width - 1, height - 1),
|
||||||
(color_space)pixelFormat, 0, bytesPerRow);
|
(color_space)pixelFormat, 0, bytesPerRow);
|
||||||
|
|
||||||
if (!bitmap.IsValid())
|
if (!bitmap.IsValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
memcpy(bitmap.Bits(), data, height * bytesPerRow);
|
memcpy(bitmap.Bits(), data, height * bytesPerRow);
|
||||||
|
|
||||||
view->ConvertToScreenForDrawing(&dest);
|
view->ConvertToScreenForDrawing(&dest);
|
||||||
|
|
||||||
view->Window()->GetDrawingEngine()->DrawBitmap(&bitmap, src, dest,
|
view->Window()->GetDrawingEngine()->DrawBitmap(&bitmap, src, dest,
|
||||||
options);
|
options);
|
||||||
}
|
}
|
||||||
@@ -447,10 +448,10 @@ draw_pixels(View *view, BRect src, BRect dest, int32 width, int32 height,
|
|||||||
static void
|
static void
|
||||||
draw_picture(View *view, BPoint where, int32 token)
|
draw_picture(View *view, BPoint where, int32 token)
|
||||||
{
|
{
|
||||||
ServerPicture *picture = view->Window()->ServerWindow()->App()->FindPicture(token);
|
ServerPicture *picture = view->Window()->ServerWindow()->App()->FindPicture(token);
|
||||||
if (picture != NULL) {
|
if (picture != NULL) {
|
||||||
view->SetDrawingOrigin(where);
|
view->SetDrawingOrigin(where);
|
||||||
view->PushState();
|
view->PushState();
|
||||||
picture->Play(view);
|
picture->Play(view);
|
||||||
view->PopState();
|
view->PopState();
|
||||||
}
|
}
|
||||||
@@ -465,7 +466,7 @@ set_clipping_rects(View *view, const BRect *rects, uint32 numRects)
|
|||||||
BRegion region;
|
BRegion region;
|
||||||
for (uint32 c = 0; c < numRects; c++)
|
for (uint32 c = 0; c < numRects; c++)
|
||||||
region.Include(rects[c]);
|
region.Include(rects[c]);
|
||||||
view->SetUserClipping(®ion);
|
view->SetUserClipping(®ion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -512,7 +513,7 @@ exit_state_change(View *view)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
enter_font_state(View *view)
|
enter_font_state(View *view)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -525,7 +526,7 @@ exit_font_state(View *view)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_origin(View *view, BPoint pt)
|
set_origin(View *view, BPoint pt)
|
||||||
{
|
{
|
||||||
view->CurrentState()->SetOrigin(pt);
|
view->CurrentState()->SetOrigin(pt);
|
||||||
@@ -600,7 +601,7 @@ set_scale(View *view, float scale)
|
|||||||
{
|
{
|
||||||
view->CurrentState()->SetScale(scale);
|
view->CurrentState()->SetScale(scale);
|
||||||
view->Window()->ServerWindow()->ResyncDrawState();
|
view->Window()->ServerWindow()->ResyncDrawState();
|
||||||
|
|
||||||
// Update the drawing engine draw state, since some stuff (for example
|
// Update the drawing engine draw state, since some stuff (for example
|
||||||
// the pen size) needs to be recalculated.
|
// the pen size) needs to be recalculated.
|
||||||
}
|
}
|
||||||
@@ -746,7 +747,7 @@ const static void *kTableEntries[] = {
|
|||||||
(const void *)set_font_shear,
|
(const void *)set_font_shear,
|
||||||
(const void *)reserved, // TODO: Marc Flerackers calls this "set_font_bpp". Investigate
|
(const void *)reserved, // TODO: Marc Flerackers calls this "set_font_bpp". Investigate
|
||||||
(const void *)set_font_face,
|
(const void *)set_font_face,
|
||||||
(const void *)set_blending_mode
|
(const void *)set_blending_mode
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -761,7 +762,7 @@ ServerPicture::ServerPicture()
|
|||||||
{
|
{
|
||||||
fToken = gTokenSpace.NewToken(kPictureToken, this);
|
fToken = gTokenSpace.NewToken(kPictureToken, this);
|
||||||
fData = new (std::nothrow) BMallocIO();
|
fData = new (std::nothrow) BMallocIO();
|
||||||
|
|
||||||
PictureDataWriter::SetTo(fData);
|
PictureDataWriter::SetTo(fData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -781,13 +782,13 @@ ServerPicture::ServerPicture(const ServerPicture &picture)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
fData = mallocIO;
|
fData = mallocIO;
|
||||||
|
|
||||||
const off_t size = picture.DataLength();
|
const off_t size = picture.DataLength();
|
||||||
if (mallocIO->SetSize(size) < B_OK)
|
if (mallocIO->SetSize(size) < B_OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
picture.fData->ReadAt(0, const_cast<void *>(mallocIO->Buffer()), size);
|
picture.fData->ReadAt(0, const_cast<void *>(mallocIO->Buffer()), size);
|
||||||
|
|
||||||
PictureDataWriter::SetTo(fData);
|
PictureDataWriter::SetTo(fData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -801,7 +802,7 @@ ServerPicture::ServerPicture(const char *fileName, const int32 &offset)
|
|||||||
fUsurped(NULL)
|
fUsurped(NULL)
|
||||||
{
|
{
|
||||||
fToken = gTokenSpace.NewToken(kPictureToken, this);
|
fToken = gTokenSpace.NewToken(kPictureToken, this);
|
||||||
|
|
||||||
fFile = new (std::nothrow) BFile(fileName, B_READ_WRITE);
|
fFile = new (std::nothrow) BFile(fileName, B_READ_WRITE);
|
||||||
if (fFile == NULL)
|
if (fFile == NULL)
|
||||||
return;
|
return;
|
||||||
@@ -824,7 +825,7 @@ ServerPicture::~ServerPicture()
|
|||||||
delete fData;
|
delete fData;
|
||||||
delete fFile;
|
delete fFile;
|
||||||
gTokenSpace.RemoveToken(fToken);
|
gTokenSpace.RemoveToken(fToken);
|
||||||
|
|
||||||
// We only delete the subpictures list, not the subpictures themselves,
|
// We only delete the subpictures list, not the subpictures themselves,
|
||||||
// since the ServerApp keeps them in a list and will delete them on quit.
|
// since the ServerApp keeps them in a list and will delete them on quit.
|
||||||
delete fPictures;
|
delete fPictures;
|
||||||
@@ -859,7 +860,7 @@ ServerPicture::SyncState(View *view)
|
|||||||
view->CurrentState()->MiterLimit());
|
view->CurrentState()->MiterLimit());
|
||||||
//WriteSetPattern(*view->CurrentState()->GetPattern().GetInt8());
|
//WriteSetPattern(*view->CurrentState()->GetPattern().GetInt8());
|
||||||
WriteSetDrawingMode(view->CurrentState()->GetDrawingMode());
|
WriteSetDrawingMode(view->CurrentState()->GetDrawingMode());
|
||||||
|
|
||||||
WriteSetHighColor(view->CurrentState()->HighColor());
|
WriteSetHighColor(view->CurrentState()->HighColor());
|
||||||
WriteSetLowColor(view->CurrentState()->LowColor());
|
WriteSetLowColor(view->CurrentState()->LowColor());
|
||||||
|
|
||||||
@@ -888,10 +889,10 @@ ServerPicture::SetFontFromLink(BPrivate::LinkReceiver& link)
|
|||||||
link.Read<float>(&size);
|
link.Read<float>(&size);
|
||||||
WriteSetFontSize(size);
|
WriteSetFontSize(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mask & B_FONT_SHEAR) {
|
if (mask & B_FONT_SHEAR) {
|
||||||
float shear;
|
float shear;
|
||||||
link.Read<float>(&shear);
|
link.Read<float>(&shear);
|
||||||
WriteSetFontShear(shear);
|
WriteSetFontShear(shear);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -969,7 +970,7 @@ ServerPicture::NestPicture(ServerPicture *picture)
|
|||||||
{
|
{
|
||||||
if (fPictures == NULL)
|
if (fPictures == NULL)
|
||||||
fPictures = new (std::nothrow) BList;
|
fPictures = new (std::nothrow) BList;
|
||||||
|
|
||||||
if (fPictures == NULL
|
if (fPictures == NULL
|
||||||
|| !fPictures->AddItem(picture))
|
|| !fPictures->AddItem(picture))
|
||||||
return false;
|
return false;
|
||||||
@@ -985,13 +986,13 @@ ServerPicture::DataLength() const
|
|||||||
return 0;
|
return 0;
|
||||||
off_t size;
|
off_t size;
|
||||||
fData->GetSize(&size);
|
fData->GetSize(&size);
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
ServerPicture::ImportData(BPrivate::LinkReceiver &link)
|
ServerPicture::ImportData(BPrivate::LinkReceiver &link)
|
||||||
{
|
{
|
||||||
int32 size = 0;
|
int32 size = 0;
|
||||||
link.Read<int32>(&size);
|
link.Read<int32>(&size);
|
||||||
|
|
||||||
@@ -1027,9 +1028,9 @@ ServerPicture::ExportData(BPrivate::PortLink &link)
|
|||||||
link.Attach<int32>(subPicturesCount);
|
link.Attach<int32>(subPicturesCount);
|
||||||
if (subPicturesCount > 0) {
|
if (subPicturesCount > 0) {
|
||||||
for (int32 i = 0; i < subPicturesCount; i++) {
|
for (int32 i = 0; i < subPicturesCount; i++) {
|
||||||
ServerPicture *subPic = static_cast<ServerPicture *>(fPictures->ItemAtFast(i));
|
ServerPicture *subPic = static_cast<ServerPicture *>(fPictures->ItemAtFast(i));
|
||||||
link.Attach<int32>(subPic->Token());
|
link.Attach<int32>(subPic->Token());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
off_t size = 0;
|
off_t size = 0;
|
||||||
|
|||||||
@@ -50,6 +50,7 @@
|
|||||||
|
|
||||||
#include <AppDefs.h>
|
#include <AppDefs.h>
|
||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
|
#include <Debug.h>
|
||||||
#include <DirectWindow.h>
|
#include <DirectWindow.h>
|
||||||
#include <TokenSpace.h>
|
#include <TokenSpace.h>
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include "PathList.h"
|
#include "PathList.h"
|
||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "ObjectList.h"
|
#include "ObjectList.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
BObjectList<MediaFilePlayer> list;
|
BObjectList<MediaFilePlayer> list;
|
||||||
|
|
||||||
@@ -35,12 +36,12 @@ PlayMediaFile(const char *media_type, const char *media_name)
|
|||||||
player->Restart();
|
player->Restart();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
list.RemoveItem(player);
|
list.RemoveItem(player);
|
||||||
delete player;
|
delete player;
|
||||||
player = NULL;
|
player = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!player) {
|
if (!player) {
|
||||||
player = new MediaFilePlayer(media_type, media_name, &ref);
|
player = new MediaFilePlayer(media_type, media_name, &ref);
|
||||||
if (player->InitCheck() == B_OK)
|
if (player->InitCheck() == B_OK)
|
||||||
@@ -60,39 +61,39 @@ MediaFilePlayer::MediaFilePlayer(const char *media_type,
|
|||||||
fPlayTrack(NULL)
|
fPlayTrack(NULL)
|
||||||
{
|
{
|
||||||
fName = strdup(media_name);
|
fName = strdup(media_name);
|
||||||
|
|
||||||
fPlayFile = new BMediaFile(&fRef);
|
fPlayFile = new BMediaFile(&fRef);
|
||||||
if ((fInitCheck = fPlayFile->InitCheck()) <B_OK) {
|
if ((fInitCheck = fPlayFile->InitCheck()) <B_OK) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&fPlayFormat, 0, sizeof(fPlayFormat));
|
memset(&fPlayFormat, 0, sizeof(fPlayFormat));
|
||||||
|
|
||||||
for (int i=0; i < fPlayFile->CountTracks(); i++) {
|
for (int i=0; i < fPlayFile->CountTracks(); i++) {
|
||||||
BMediaTrack *track = fPlayFile->TrackAt(i);
|
BMediaTrack *track = fPlayFile->TrackAt(i);
|
||||||
if (track == NULL)
|
if (track == NULL)
|
||||||
continue;
|
continue;
|
||||||
fPlayFormat.type = B_MEDIA_RAW_AUDIO;
|
fPlayFormat.type = B_MEDIA_RAW_AUDIO;
|
||||||
fPlayFormat.u.raw_audio.buffer_size = 256;
|
fPlayFormat.u.raw_audio.buffer_size = 256;
|
||||||
if ((track->DecodedFormat(&fPlayFormat) == B_OK)
|
if ((track->DecodedFormat(&fPlayFormat) == B_OK)
|
||||||
&& (fPlayFormat.type == B_MEDIA_RAW_AUDIO)) {
|
&& (fPlayFormat.type == B_MEDIA_RAW_AUDIO)) {
|
||||||
fPlayTrack = track;
|
fPlayTrack = track;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fPlayFile->ReleaseTrack(track);
|
fPlayFile->ReleaseTrack(track);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fPlayTrack == NULL) {
|
if (fPlayTrack == NULL) {
|
||||||
fInitCheck = B_BAD_VALUE;
|
fInitCheck = B_BAD_VALUE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fSoundPlayer = new BSoundPlayer(&fPlayFormat.u.raw_audio, media_name, PlayFunction,
|
fSoundPlayer = new BSoundPlayer(&fPlayFormat.u.raw_audio, media_name, PlayFunction,
|
||||||
NULL, this);
|
NULL, this);
|
||||||
if ((fInitCheck = fSoundPlayer->InitCheck()) != B_OK) {
|
if ((fInitCheck = fSoundPlayer->InitCheck()) != B_OK) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fSoundPlayer->SetVolume(1.0f);
|
fSoundPlayer->SetVolume(1.0f);
|
||||||
fSoundPlayer->SetHasData(true);
|
fSoundPlayer->SetHasData(true);
|
||||||
fSoundPlayer->Start();
|
fSoundPlayer->Start();
|
||||||
@@ -134,7 +135,7 @@ MediaFilePlayer::Restart()
|
|||||||
void
|
void
|
||||||
MediaFilePlayer::Stop()
|
MediaFilePlayer::Stop()
|
||||||
{
|
{
|
||||||
fSoundPlayer->Stop();
|
fSoundPlayer->Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -144,7 +145,7 @@ MediaFilePlayer::PlayFunction(void *cookie, void * buffer, size_t size, const me
|
|||||||
MediaFilePlayer *player = (MediaFilePlayer *)cookie;
|
MediaFilePlayer *player = (MediaFilePlayer *)cookie;
|
||||||
int64 frames = 0;
|
int64 frames = 0;
|
||||||
player->fPlayTrack->ReadFrames(buffer, &frames);
|
player->fPlayTrack->ReadFrames(buffer, &frames);
|
||||||
|
|
||||||
if (frames <=0) {
|
if (frames <=0) {
|
||||||
player->fSoundPlayer->SetHasData(false);
|
player->fSoundPlayer->SetHasData(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
// BeOS
|
// BeOS
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
|
#include <Debug.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
|
|
||||||
@@ -55,7 +56,7 @@ static struct PageFormat
|
|||||||
char *label;
|
char *label;
|
||||||
float width;
|
float width;
|
||||||
float height;
|
float height;
|
||||||
} pageFormat[] =
|
} pageFormat[] =
|
||||||
{
|
{
|
||||||
{"Letter", letter_width, letter_height },
|
{"Letter", letter_width, letter_height },
|
||||||
{"Legal", legal_width, legal_height },
|
{"Legal", legal_width, legal_height },
|
||||||
@@ -81,7 +82,7 @@ static void GetPageFormat(float w, float h, BString& label)
|
|||||||
label = pf.label; return;
|
label = pf.label; return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float unit = 72.0; // currently inc[h]es only
|
float unit = 72.0; // currently inc[h]es only
|
||||||
label << (w / unit) << "x" << (h / unit) << " in.";
|
label << (w / unit) << "x" << (h / unit) << " in.";
|
||||||
}
|
}
|
||||||
@@ -105,31 +106,31 @@ ConfigWindow::ConfigWindow(config_setup_kind kind, Printer* defaultPrinter,
|
|||||||
if (kind == kJobSetup)
|
if (kind == kJobSetup)
|
||||||
SetTitle("Print Setup");
|
SetTitle("Print Setup");
|
||||||
|
|
||||||
BView* panel = new BBox(Bounds(), "top_panel", B_FOLLOW_ALL,
|
BView* panel = new BBox(Bounds(), "top_panel", B_FOLLOW_ALL,
|
||||||
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP,
|
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP,
|
||||||
B_PLAIN_BORDER);
|
B_PLAIN_BORDER);
|
||||||
|
|
||||||
AddChild(panel);
|
AddChild(panel);
|
||||||
|
|
||||||
float left = 10, top = 10;
|
float left = 10, top = 10;
|
||||||
BRect r(left, top, 160, 20);
|
BRect r(left, top, 160, 20);
|
||||||
|
|
||||||
// print selection popup menu
|
// print selection popup menu
|
||||||
BPopUpMenu* menu = new BPopUpMenu("Select a Printer");
|
BPopUpMenu* menu = new BPopUpMenu("Select a Printer");
|
||||||
SetupPrintersMenu(menu);
|
SetupPrintersMenu(menu);
|
||||||
|
|
||||||
float width = be_plain_font->StringWidth("Printer:") + 10.0;
|
float width = be_plain_font->StringWidth("Printer:") + 10.0;
|
||||||
r.right = r.left + width + menu->MaxContentWidth() + 10;
|
r.right = r.left + width + menu->MaxContentWidth() + 10;
|
||||||
fPrinters = new BMenuField(r, "Printer", "Printer:", menu);
|
fPrinters = new BMenuField(r, "Printer", "Printer:", menu);
|
||||||
fPrinters->SetDivider(width);
|
fPrinters->SetDivider(width);
|
||||||
panel->AddChild(fPrinters);
|
panel->AddChild(fPrinters);
|
||||||
top += fPrinters->Bounds().Height() + 10;
|
top += fPrinters->Bounds().Height() + 10;
|
||||||
|
|
||||||
// page format button
|
// page format button
|
||||||
r.OffsetTo(left, top);
|
r.OffsetTo(left, top);
|
||||||
fPageSetup = AddPictureButton(panel, r, "Page Format", "PAGE_SETUP_ON",
|
fPageSetup = AddPictureButton(panel, r, "Page Format", "PAGE_SETUP_ON",
|
||||||
"PAGE_SETUP_OFF", MSG_PAGE_SETUP);
|
"PAGE_SETUP_OFF", MSG_PAGE_SETUP);
|
||||||
|
|
||||||
// add description to button
|
// add description to button
|
||||||
r.OffsetTo(left + fPageSetup->Bounds().Width() + 5, fPageSetup->Frame().top);
|
r.OffsetTo(left + fPageSetup->Bounds().Width() + 5, fPageSetup->Frame().top);
|
||||||
BStringView *stringView = AddStringView(panel, r, "Paper Setup:");
|
BStringView *stringView = AddStringView(panel, r, "Paper Setup:");
|
||||||
@@ -139,7 +140,7 @@ ConfigWindow::ConfigWindow(config_setup_kind kind, Printer* defaultPrinter,
|
|||||||
fPageFormatText = AddStringView(panel, r, "");
|
fPageFormatText = AddStringView(panel, r, "");
|
||||||
fPageFormatText->ResizeToPreferred();
|
fPageFormatText->ResizeToPreferred();
|
||||||
top = fPageSetup->Frame().bottom + 15;
|
top = fPageSetup->Frame().bottom + 15;
|
||||||
|
|
||||||
// page selection button
|
// page selection button
|
||||||
fJobSetup = NULL;
|
fJobSetup = NULL;
|
||||||
if (kind == kJobSetup) {
|
if (kind == kJobSetup) {
|
||||||
@@ -156,14 +157,14 @@ ConfigWindow::ConfigWindow(config_setup_kind kind, Printer* defaultPrinter,
|
|||||||
top = fJobSetup->Frame().bottom + 15;
|
top = fJobSetup->Frame().bottom + 15;
|
||||||
}
|
}
|
||||||
top += 5;
|
top += 5;
|
||||||
|
|
||||||
// separator line
|
// separator line
|
||||||
BRect line(Bounds());
|
BRect line(Bounds());
|
||||||
line.OffsetTo(0, top);
|
line.OffsetTo(0, top);
|
||||||
line.bottom = line.top+1;
|
line.bottom = line.top+1;
|
||||||
AddChild(new BBox(line, "line", B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP));
|
AddChild(new BBox(line, "line", B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP));
|
||||||
top += 10;
|
top += 10;
|
||||||
|
|
||||||
// Cancel button
|
// Cancel button
|
||||||
r.OffsetTo(left, top);
|
r.OffsetTo(left, top);
|
||||||
BButton* cancel = new BButton(r, "Cancel", "Cancel",
|
BButton* cancel = new BButton(r, "Cancel", "Cancel",
|
||||||
@@ -171,7 +172,7 @@ ConfigWindow::ConfigWindow(config_setup_kind kind, Printer* defaultPrinter,
|
|||||||
panel->AddChild(cancel);
|
panel->AddChild(cancel);
|
||||||
cancel->ResizeToPreferred();
|
cancel->ResizeToPreferred();
|
||||||
left = cancel->Frame().right + 10;
|
left = cancel->Frame().right + 10;
|
||||||
|
|
||||||
// OK button
|
// OK button
|
||||||
r.OffsetTo(left, top);
|
r.OffsetTo(left, top);
|
||||||
fOk = new BButton(r, "OK", "OK", new BMessage(MSG_OK));
|
fOk = new BButton(r, "OK", "OK", new BMessage(MSG_OK));
|
||||||
@@ -179,15 +180,15 @@ ConfigWindow::ConfigWindow(config_setup_kind kind, Printer* defaultPrinter,
|
|||||||
fOk->ResizeToPreferred();
|
fOk->ResizeToPreferred();
|
||||||
top += fOk->Bounds().Height() + 10;
|
top += fOk->Bounds().Height() + 10;
|
||||||
|
|
||||||
// resize window
|
// resize window
|
||||||
ResizeTo(fOk->Frame().right + 10, top);
|
ResizeTo(fOk->Frame().right + 10, top);
|
||||||
|
|
||||||
AddShortcut('i', 0, new BMessage(B_ABOUT_REQUESTED));
|
AddShortcut('i', 0, new BMessage(B_ABOUT_REQUESTED));
|
||||||
|
|
||||||
SetDefaultButton(fOk);
|
SetDefaultButton(fOk);
|
||||||
|
|
||||||
fPrinters->MakeFocus(true);
|
fPrinters->MakeFocus(true);
|
||||||
|
|
||||||
UpdateSettings(true);
|
UpdateSettings(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,7 +245,7 @@ void ConfigWindow::MessageReceived(BMessage* m)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char*
|
static const char*
|
||||||
kAbout =
|
kAbout =
|
||||||
"Printer Server\n"
|
"Printer Server\n"
|
||||||
"© 2001-2008 Haiku\n"
|
"© 2001-2008 Haiku\n"
|
||||||
@@ -293,32 +294,32 @@ BPictureButton* ConfigWindow::AddPictureButton(BView* panel, BRect frame,
|
|||||||
{
|
{
|
||||||
BBitmap* onBM = LoadBitmap(on);
|
BBitmap* onBM = LoadBitmap(on);
|
||||||
BBitmap* offBM = LoadBitmap(off);
|
BBitmap* offBM = LoadBitmap(off);
|
||||||
|
|
||||||
BPicture* onPict = BitmapToPicture(panel, onBM);
|
BPicture* onPict = BitmapToPicture(panel, onBM);
|
||||||
BPicture* offPict = BitmapToPicture(panel, offBM);
|
BPicture* offPict = BitmapToPicture(panel, offBM);
|
||||||
|
|
||||||
BPictureButton* button = NULL;
|
BPictureButton* button = NULL;
|
||||||
|
|
||||||
if (onPict != NULL && offPict != NULL) {
|
if (onPict != NULL && offPict != NULL) {
|
||||||
button = new BPictureButton(frame, name, onPict, offPict, new BMessage(what));
|
button = new BPictureButton(frame, name, onPict, offPict, new BMessage(what));
|
||||||
button->SetViewColor(B_TRANSPARENT_COLOR);
|
button->SetViewColor(B_TRANSPARENT_COLOR);
|
||||||
panel->AddChild(button);
|
panel->AddChild(button);
|
||||||
onBM->Lock();
|
onBM->Lock();
|
||||||
button->ResizeTo(onBM->Bounds().Width(), onBM->Bounds().Height());
|
button->ResizeTo(onBM->Bounds().Width(), onBM->Bounds().Height());
|
||||||
onBM->Unlock();
|
onBM->Unlock();
|
||||||
|
|
||||||
BPicture* disabled = BitmapToGrayedPicture(panel, offBM);
|
BPicture* disabled = BitmapToGrayedPicture(panel, offBM);
|
||||||
button->SetDisabledOn(disabled);
|
button->SetDisabledOn(disabled);
|
||||||
delete disabled;
|
delete disabled;
|
||||||
|
|
||||||
disabled = BitmapToGrayedPicture(panel, onBM);
|
disabled = BitmapToGrayedPicture(panel, onBM);
|
||||||
button->SetDisabledOff(disabled);
|
button->SetDisabledOff(disabled);
|
||||||
delete disabled;
|
delete disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete onPict; delete offPict;
|
delete onPict; delete offPict;
|
||||||
delete onBM; delete offBM;
|
delete onBM; delete offBM;
|
||||||
|
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -430,21 +431,21 @@ void ConfigWindow::UpdateUI()
|
|||||||
fOk->SetEnabled(false);
|
fOk->SetEnabled(false);
|
||||||
fPageFormatText->SetText("Undefined paper format");
|
fPageFormatText->SetText("Undefined paper format");
|
||||||
fPageFormatText->ResizeToPreferred();
|
fPageFormatText->ResizeToPreferred();
|
||||||
} else {
|
} else {
|
||||||
fPageSetup->SetEnabled(true);
|
fPageSetup->SetEnabled(true);
|
||||||
|
|
||||||
if (fJobSetup)
|
if (fJobSetup)
|
||||||
fJobSetup->SetEnabled(fKind == kJobSetup && !fPageSettings.IsEmpty());
|
fJobSetup->SetEnabled(fKind == kJobSetup && !fPageSettings.IsEmpty());
|
||||||
|
|
||||||
fOk->SetEnabled(fKind == kJobSetup && !fJobSettings.IsEmpty() ||
|
fOk->SetEnabled(fKind == kJobSetup && !fJobSettings.IsEmpty() ||
|
||||||
fKind == kPageSetup && !fPageSettings.IsEmpty());
|
fKind == kPageSetup && !fPageSettings.IsEmpty());
|
||||||
|
|
||||||
// display information about page format
|
// display information about page format
|
||||||
BRect paperRect;
|
BRect paperRect;
|
||||||
BString pageFormat;
|
BString pageFormat;
|
||||||
if (fPageSettings.FindRect(PSRV_FIELD_PAPER_RECT, &paperRect) == B_OK) {
|
if (fPageSettings.FindRect(PSRV_FIELD_PAPER_RECT, &paperRect) == B_OK) {
|
||||||
GetPageFormat(paperRect.Width(), paperRect.Height(), pageFormat);
|
GetPageFormat(paperRect.Width(), paperRect.Height(), pageFormat);
|
||||||
|
|
||||||
int32 orientation = 0;
|
int32 orientation = 0;
|
||||||
fPageSettings.FindInt32(PSRV_FIELD_ORIENTATION, &orientation);
|
fPageSettings.FindInt32(PSRV_FIELD_ORIENTATION, &orientation);
|
||||||
if (orientation == 0)
|
if (orientation == 0)
|
||||||
@@ -463,7 +464,7 @@ void ConfigWindow::UpdateUI()
|
|||||||
int32 first, last;
|
int32 first, last;
|
||||||
if (fJobSettings.FindInt32(PSRV_FIELD_FIRST_PAGE, &first) == B_OK &&
|
if (fJobSettings.FindInt32(PSRV_FIELD_FIRST_PAGE, &first) == B_OK &&
|
||||||
fJobSettings.FindInt32(PSRV_FIELD_LAST_PAGE, &last) == B_OK) {
|
fJobSettings.FindInt32(PSRV_FIELD_LAST_PAGE, &last) == B_OK) {
|
||||||
if (first >= 1 && first <= last && last != INT_MAX) {
|
if (first >= 1 && first <= last && last != INT_MAX) {
|
||||||
job << "From page " << first << " to " << last;
|
job << "From page " << first << " to " << last;
|
||||||
} else {
|
} else {
|
||||||
job << "All pages";
|
job << "All pages";
|
||||||
@@ -496,17 +497,17 @@ void ConfigWindow::Setup(config_setup_kind kind)
|
|||||||
if (fCurrentPrinter) {
|
if (fCurrentPrinter) {
|
||||||
Hide();
|
Hide();
|
||||||
if (kind == kPageSetup) {
|
if (kind == kPageSetup) {
|
||||||
BMessage settings = fPageSettings;
|
BMessage settings = fPageSettings;
|
||||||
if (fCurrentPrinter->ConfigurePage(settings) == B_OK) {
|
if (fCurrentPrinter->ConfigurePage(settings) == B_OK) {
|
||||||
fPageSettings = settings;
|
fPageSettings = settings;
|
||||||
if (!fJobSettings.IsEmpty())
|
if (!fJobSettings.IsEmpty())
|
||||||
AddFields(&fJobSettings, &fPageSettings);
|
AddFields(&fJobSettings, &fPageSettings);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
BMessage settings;
|
BMessage settings;
|
||||||
if (fJobSettings.IsEmpty()) settings = fPageSettings;
|
if (fJobSettings.IsEmpty()) settings = fPageSettings;
|
||||||
else settings = fJobSettings;
|
else settings = fJobSettings;
|
||||||
|
|
||||||
if (fCurrentPrinter->ConfigureJob(settings) == B_OK)
|
if (fCurrentPrinter->ConfigureJob(settings) == B_OK)
|
||||||
fJobSettings = settings;
|
fJobSettings = settings;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user